Skeeve has asked for the wisdom of the Perl Monks concerning the following question:
I first wanted to write:
but then wrote insteadwhile(<>) { chomp; push(@{$para{$_}}, $ARGV); }
because it's shorter.chomp,push(@{$para{$_}}, $ARGV) for (<>);
Unfortunately both versions are not equivalent. $ARGV is always the $ARGV[$#ARGV] in the for loop, while it changes to the current filename in the first loop.
Is this a documented feature?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: while or for?
by broquaint (Abbot) on Jul 21, 2003 at 10:24 UTC | |
by Skeeve (Parson) on Jul 21, 2003 at 10:31 UTC | |
|
Re: while or for?
by edan (Curate) on Jul 21, 2003 at 10:57 UTC | |
|
(jeffa) Re: while or for?
by jeffa (Bishop) on Jul 21, 2003 at 13:34 UTC | |
by Skeeve (Parson) on Jul 22, 2003 at 05:38 UTC | |
|
Re: while or for?
by antirice (Priest) on Jul 21, 2003 at 13:23 UTC | |
|
Re: while or for?
by tilly (Archbishop) on Jul 21, 2003 at 21:11 UTC | |
by Skeeve (Parson) on Jul 22, 2003 at 05:43 UTC |