Or if you don't want to test the length of your array forevermore:
my @history = ("\n") x 3; while (<>) { print @history if /pattern/; push @history, $_; shift @history; }
In reply to Re^2: How can I print three lines before pattern match?
by Narveson
in thread How can I print three lines before pattern match?
by neurotoxx
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |