in reply to Print n lines after a matched line
Discipulus solution above is very elegant. Here's the correction of the error in your script:
use strict; use warnings; my $file = "input.txt"; my @data; open (IN,"<","$file"); my $count = 0; while (<IN>) { $count = 1 if /SCHEDULE\s"(DUMMY\sCHECK)".*/; if ($count >= 1 and $count <= 6) { - @data = $_; - print @data; + $_ = <IN>; + print; $count++; } }
You did not read the next line off your input file descriptor.
|
|---|