Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: searching for multiple lines from outfile and printing them all in the final outfile

by McDarren (Abbot)
on May 16, 2009 at 04:23 UTC ( #764388=note: print w/ replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://764388]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2014-12-21 17:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (106 votes), past polls