http://qs321.pair.com?node_id=86772


in reply to Re: print line 5 lines previous to comaprison line!
in thread print line 5 lines previous to comaprison line!

Nice. One suggestion:
# change: print $buffer[0] if /$pat/; # to: print $buffer[0] if /\Q$pat\E/o;
The \Q and \E presume that $pat is just a string, not a regex. So you would want to escape any special characters (like '.' or '+' ) and the o tells Perl that $pat isn't going to change in the loop, so it won't keep recompiling the pattern.