in reply to Re^2: Filtering Output from two files
in thread Filtering Output from two files
He meant that the following lines are inside of a loop, like this:
# read file1 into a %hash ... code to do that here ... # inside a loop while (my $line = <$file2>) { # read file2 line by line ... this was done in the loop condition above ... # split the $line to @fields at | # if the first $fields[0] exists in the %hash, # print the whole $line to file 3 }
This is a relatively common question, so LanX gave you the outline of a good solution to the problem.
A frequent mistake is to try to read *both* files inside the loop, giving one of two bad outcomes:
(1) Extremely slowly in the relative sense--for small files you may not notice it. But if your files get large enough, you'll wonder why such a fast computer is so freakin' slow.
...roboticus
When your only tool is a hammer, all problems look like your thumb.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Filtering Output from two files
by vighneshmufc (Acolyte) on Feb 04, 2018 at 15:09 UTC | |
by AnomalousMonk (Archbishop) on Feb 04, 2018 at 16:18 UTC | |
by LanX (Saint) on Feb 04, 2018 at 17:45 UTC | |
by AnomalousMonk (Archbishop) on Feb 04, 2018 at 18:35 UTC | |
by Laurent_R (Canon) on Feb 04, 2018 at 21:40 UTC | |
by LanX (Saint) on Feb 04, 2018 at 23:38 UTC | |
by LanX (Saint) on Feb 04, 2018 at 18:40 UTC | |
by AnomalousMonk (Archbishop) on Feb 04, 2018 at 19:06 UTC | |
|