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?

Print the empty string prints nothing. Printing a newline prints an empty line.
my @history = ('') x 3; while (<>) { print @history, $_ if /pattern/; push @history, $_; shift @history; }
or
my @history = ('') x 4; while (<>) { push @history, $_; shift @history; print @history, $_ if /pattern/; }