Advertisements

On Feb 7, 2:27 am, Deepu <> wrote:
> I need some help for a scenario explained below.

This is a typical data munging task. Pseudo code for your script is as
follows, at least as a first step:

open file A
for each line in file A
- split the line
- stuff the values into a suitable data structure (perhaps %A)
close file A

open file B
for each line in file B
- split the line
- stuff the values into a suitable data structure (perhaps %B)
close file B

iterate through %A
- if there is a match with an element of %B, print

From the appearance of your data, you could probably throw away the
first three directories, tb, device, and logic. It strikes me that (as
a first try) you might want to replace the delimiter in each line to a
common delimiter, perhaps a colon, save the whole thing as a string,
and then use a regular expression to match against the string.

From there, you can optimize, perhaps by just saving the values in the
first file as an array of strings, and directly match the values in
the second file without using a second data structure. This depends on
the nature of your data, and if your data is sorted in some kind of
way, the task become much easier.

Your question isn't a Perl question as such, but more of a general
question applicable to whatever language you would want to use,
although Perl can certainly handle this task with ease and speed.

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!