my ($buf, $onelineback, $twolinesback, $thisline); while($buf = <IN>) { if ($buf =~ /somestring/) { if defined($twolinesback) { print $twolinesback; } else { print "Matched, but not enough lines read yet\n"; } } $twolinesback = $onelineback; $onelineback = $thisline; $thisline = $buf; }
In reply to Re: newbie question
by Cabrion
in thread Reading a value two lines before the current line
by stu96art
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |