in reply to Re: How to match previous line
in thread How to match previous line

Considering that $previous is defined most of the time, it's better to check $line =~ /BEEP/ first. Or just eliminate the check for definedness all together:
my $previous = ""; while (<$handle>) { print $previous if /BEEP/; $previous = $_; }
If "BEEP" is on the first line, it just prints nothing. Which is the same effect as not printing (assuming no assignment to $\ has been done).