Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Using the while (<>) construction takes a file from the command line and parses each individual line of the file (up to the \n). How do I 'peek' at the next line in the file without losing my current place? Doing something like:
my $nextLine = <>
would skip the current line, but all I want to do is check the next line for before processing the current line.
I have written all sorts of convoluted test code, trying to fiddle with line numbers, the @ARGV array, the $_ variable, but nothing has worked so far.
Many thanks for your help.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How to 'peek' at next line while parsing with <>
by japhy (Canon) on Jul 11, 2002 at 16:57 UTC | |
Re: How to 'peek' at next line while parsing with <>
by Abigail-II (Bishop) on Jul 11, 2002 at 17:14 UTC | |
Re: How to 'peek' at next line while parsing with <>
by talexb (Chancellor) on Jul 11, 2002 at 16:59 UTC | |
by DamnDirtyApe (Curate) on Jul 11, 2002 at 17:08 UTC | |
Re: How to 'peek' at next line while parsing with <>
by BrowserUk (Patriarch) on Jul 11, 2002 at 17:08 UTC | |
Re: How to 'peek' at next line while parsing with <>
by particle (Vicar) on Jul 11, 2002 at 18:38 UTC | |
Re: How to 'peek' at next line while parsing with <>
by TexasTess (Beadle) on Jul 11, 2002 at 18:45 UTC |
Back to
Seekers of Perl Wisdom