# 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);
In reply to Re: Reading certain lines in a file
by mrmick
in thread Reading certain lines in a file
by Ras
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |