in reply to Re: How do closures and variable scope (my,our,local) interact in perl?
in thread How do closures and variable scope (my,our,local) interact in perl?
Wow. @colors was modified. Didn't think of that. That explains a lot. So it all boils down to a subtle difference between localizing and aliasing:
In the above quote from perlsyn it says both my and our are localized and doesn't make a distinction between aliasing and localizing. In your opinion is this a documentation bug? a perl bug? or neither?
Thanks, beth
Update: LanX's comment below is helpful here. He points out that lexical variables (i.e. my $name) can't be localized, so temporary aliasing is a way of faking it. Inside the loop itself, temporary aliasing is pretty much indistinguishable from localizing, but the differences between the two (localization and aliasing) become much more noticable if the variable is captured by a closure.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How do closures and variable scope (my,our,local) interact in perl?
by ikegami (Patriarch) on Jun 16, 2009 at 17:57 UTC | |
by ELISHEVA (Prior) on Jun 16, 2009 at 19:02 UTC | |
by ikegami (Patriarch) on Jun 16, 2009 at 19:43 UTC | |
by shmem (Chancellor) on Jun 16, 2009 at 21:29 UTC | |
by ikegami (Patriarch) on Jun 16, 2009 at 20:03 UTC | |
|
Re^3: How do closures and variable scope (my,our,local) interact in perl?
by shmem (Chancellor) on Jun 16, 2009 at 17:56 UTC |