in reply to Re^4: To initialise or not to initialise?
in thread To initialise or not to initialise?
$_="default" for my ($foo, $bar, $baz);That one surprises me that it works. I thought that the "for" statement modifier was mere syntactic sugar, since that deparses as:
But if written as a straight for loop (as it deparses to), then the variables are local to the loop. And I could've sworn I tried that once upon a time, and it didn't work...probably won't be the last time I make that mistake :)u2-4.14 $ perl -MO=Deparse ./tst foreach $_ (my($foo, $bar, $baz)) { $_ = 'default'; } ./tst syntax OK
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^6: To initialise or not to initialise?
by tilly (Archbishop) on Jun 24, 2004 at 23:19 UTC | |
by runrig (Abbot) on Jun 24, 2004 at 23:27 UTC | |
by tilly (Archbishop) on Jun 24, 2004 at 23:30 UTC | |
by Hofmator (Curate) on Jun 25, 2004 at 08:42 UTC | |
by runrig (Abbot) on Jun 25, 2004 at 18:25 UTC | |
by Hofmator (Curate) on Jun 28, 2004 at 09:11 UTC | |
Re^6: To initialise or not to initialise?
by demerphq (Chancellor) on Jun 28, 2004 at 14:00 UTC |
In Section
Seekers of Perl Wisdom