in reply to How to match previous line
use strict; use warnings; my $previous; while (my $line = <$handle>) { if (defined($previous) && $line =~ /BEEP/ ) { print $previous; } $previous = $line; }
Of course you need additional code to extract the number from $previous, but that doesn't seem to be a problem for you.
Update: as ambrus++ pointed out in the CB this is a good place to use a continue block for assigning to $previous.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to match previous line
by JavaFan (Canon) on Aug 26, 2009 at 16:33 UTC |