in reply to Re: Tidying up some dereferencing code
in thread Tidying up some dereferencing code
"Better use foreach instead of for, when you iterate over an array."
Why, they do the exact same thing:I will admit that i tend to use foreach when i iterate over a 'collection', butprint $_ for qw(foo bar baz); print $_ foreach qw(foo bar baz); $ perl -MO=Deparse foo.pl foreach $_ ('foo', 'bar', 'baz') { print $_; } foreach $_ ('foo', 'bar', 'baz') { print $_; } foo.pl syntax OK
|
|---|