One, slurp the file and parse it using subscripts. So when $line[$i] matches, u can pull $line[$i - 1] to get the other value.
Two, save the current line value into a variable which will be available on the next iteration of the loop.
while ($line = <FILE>) { if ($line is good) { dosomething($line, $lastline); } $lastline = $line; }
Three, use Tie::File.
In reply to Re: How to match previous line
by wagnerc
in thread How to match previous line
by qnguyen
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |