Harry Putnam wrote:
This is probably blindingly simple but I'm not understanding why @ARGV
is not reduced to () (no args)? in this example
[ SNIP ]
print "Now lets ditch the rest in a for loop\n";
for (@ARGV){
my $ditch = shift;
perldoc perlsyn
[ SNIP ]
Foreach Loops
[ SNIP ]
The "foreach" keyword is actually a synonym for the "for"
keyword, so you can use "foreach" for readability or "for" for
brevity.
[ SNIP ]
If any part of LIST is an array, "foreach" will get very confused
if you add or remove elements within the loop body, for example
with "splice". So don’t do that.
print "Ditching <$ditch>\n";
$ditch = '';
What is the point of assigning to $ditch if it goes out of scope at the
next line?
}
John
--
The programmer is fighting against the two most
destructive forces in the universe: entropy and
human stupidity. -- Damian Conway
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/