Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
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?
[pryrt]: 1nickt: academically, perl -MDevel::Peek -lE 'Dump(42); Dump(42.0)'
[chacham]: have you ever wanted to vote -- on a post because of the signature?
[LanX]: susure
[LanX]: good night! :)

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (13)
As of 2017-05-24 20:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?