in reply to How to 'peek' at next line while parsing with <>
Or you can use seek() and tell() to make Perl think nothing ever happened:while ($line = <>) { # redo comes HERE # do something my $next = <>; if ($next !~ /^#/) { # if the next line DOES NOT start with a "#" # reuse it and restart this iteration of the loop $line = $next; redo; } }
while ($line = <>) { # ... my $pos = tell ARGV; my $next = <>; seek ARGV, $pos, 0; # ... }
_____________________________________________________
Jeff[japhy]Pinyan:
Perl,
regex,
and perl
hacker, who'd like a job (NYC-area)
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;
|
|---|