in reply to Re: Lines above and Below a matched string
in thread Lines above and Below a matched string

derby pointed out the problem with my approach. I think BrowserUK's idea of sliding buffers is probably best, but you can salvage my approach by opening three file-handles and having them in different frames. In code:

open(IN1, "<$infile"); open(IN2, "<$infile"); open(IN3, "<$infile"); my $temp; $temp = <IN2>; # remove one dummy line from 2nd file-handle $temp = <IN3>; $temp = <IN3>; # remove two dummy lien from 3rd file-handle # Now process all three file-handles separately # in chunks of three lines

And there was a recent node on how to read a file in chunks of n lines, that may help.

-Tats