Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Reading certain lines in a file

by mrmick (Curate)
on May 24, 2001 at 18:33 UTC ( #82923=note: print w/ replies, xml ) Need Help??


in reply to Reading certain lines in a file

How about the following(untested, of course):

# read a file and set a flag (boolean) if pattern is found # we then will print the following line and reset the flag open(OUT,$outputfilename)||die "Could not open $outputfilename for out +put\n$!\n"; open(FILE,$inputfilename)||die "Could not open $inputfilename for read +ing\n$!\n"; while(<FILE>){ if($checked){ print OUT; undef $checked; next; } if(/pattern/){ $checked=1; next; } } close(FILE); close(OUT);

Mick


Comment on Re: Reading certain lines in a file
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://82923]
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: (14)
As of 2014-09-30 12:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (367 votes), past polls