in reply to How to 'peek' at next line while parsing with <>
This will do what you want - I'm using <DATA> for test purposes. use <> for yours.
#!perl -w use strict; while (<DATA>) { chomp; print "current line=$_\n"; if (/check next/) { my $pos = tell(); my $testline = <DATA>; chomp $testline; print "'next line' = $testline\n"; #do something... seek DATA, $pos, 0; } print "current line=$_\n"; } __DATA__ line 1 line 2 line 3 check next line 4 OK? line 5
Anyone know of an abbottoire going cheap?
|
|---|