in reply to Re^3: Use of "my" after Perl v5.14
in thread Use of "my" after Perl v5.14
Then I suspect, local works just like control variable in foreach loop, where I read that, if the control variable is already declared before the loop, then its value will be restored after the foreach loop ends.
E.g: -
my $packageVar = 5; foreach $packageVar (@someArr) { # Some code } print $packageVar; # Will print 5;
*EDIT: - Didn't saw this difference.. The "local" state of variable is visible accross multiple subroutines (in fact at all places in that file I guess) untill we get out of scope of that subroutine.. That is not the case with foreach loop..
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Use of "my" after Perl v5.14
by tobyink (Canon) on Sep 20, 2012 at 23:38 UTC | |
by AnomalousMonk (Archbishop) on Sep 21, 2012 at 08:51 UTC | |
by Rohit Jain (Sexton) on Sep 21, 2012 at 00:02 UTC | |
by AnomalousMonk (Archbishop) on Sep 21, 2012 at 05:00 UTC | |
by Anonymous Monk on Sep 21, 2012 at 00:19 UTC | |
by Rohit Jain (Sexton) on Sep 21, 2012 at 00:28 UTC | |
by Anonymous Monk on Sep 21, 2012 at 02:41 UTC |