in reply to Re^2: Print line before match
in thread Print line before match
Problem is you're reading one line from file1 for every line in file2 (so you soon run out of lines in file1).
I think you rather want nested loops, i.e. something along the lines of
open F1, "file1" or die $!; while (my $find = <F1>) { chomp $find; open F2, "file2" or die $!; while (<F2>) { print if /$find/ .. /frame-relay/; } }
P.S. sorry about the first reply... (it didn't look like you wanted to learn Perl).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Print line before match
by ddrew78 (Beadle) on Mar 04, 2010 at 20:27 UTC |