in reply to Re^4: How can I print three lines before pattern match?
in thread How can I print three lines before pattern match?
ormy @history = ('') x 3; while (<>) { print @history, $_ if /pattern/; push @history, $_; shift @history; }
my @history = ('') x 4; while (<>) { push @history, $_; shift @history; print @history, $_ if /pattern/; }
|
|---|