http://www.perlmonks.org?node_id=764388


in reply to Re^2: searching for multiple lines from outfile and printing them all in the final outfile
in thread searching for multiple lines from outfile and printing them all in the final outfile

The canonical way is:
open my $in_file, '<', 'some_file.txt' or die "$!\n"; while (my $line = <$in_file>) { chomp($line); # If necessary print if $line =~ /foo/; # Or some other conditional }
Update:Note that in the above example you wouldn't actually want the chomp, but it's usually a good idea if you are doing more than just printing matching lines.

Regards,
Darren

  • Comment on Re^3: searching for multiple lines from outfile and printing them all in the final outfile
  • Download Code