in reply to Print n lines after a matched line

Hello sreek3502,

If your input is somehow fixed in it's content the easiest thing is using the flip-flop operator (see flip flop at my library and in perlop):

while (<DATA>){ print if /SCHEDULE "DUMMY CHECK"/ .. /INTERVAL/; }

If you just want to print 3 lines after a match (but notice you have empty lines that count! i used 6 lines..) you can use or a count, as you already have done, or use the special variable $. (explained in perlvar ) that is line number:

my $switch; while (<DATA>){ $switch = $. if /SCHEDULE "DUMMY CHECK"/; if ( $switch and $. <= $switch + 6){ print; } }

As final note @data = $_; does not make muche sense for me: you want to split the line? dont forget also to chomp

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.