in reply to help with the diamond operator
<$foo> reads from the file. So you're reading the first line in the file, then in print reading another one and printing it. Try using $_ instead.
For clarity sake, especially in situations where speed is not as important, it's best to say something like:
while (my $line = <foo>) { print $line, "\n"; }
The code is a bit more self-explanatory to Perl newbies (and sleep/food-deprived programmers) and is less likely to be buggy if you start using things like grep that twiddle with the value of $_.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: help with
by HyperZonk (Friar) on Jul 27, 2001 at 07:19 UTC |