saintmike has asked for the wisdom of the Perl Monks concerning the following question:
Localizing a variable (and yes, I want local, not my) defined in a different package yields strange results:
The first print complains about an uninitialized value, while the second one prints the previously assigned value. Or, more generally speaking, how come that####################### package A; our $variable = 3; ####################### package main; { # I want to localize the variable in this block local $A::variable; print "$A::variable\n"; } print "$A::variable\n";
undefs $A::variable?package B; local $A::variable;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: What's wrong with this local() ?
by BrowserUk (Patriarch) on Jan 30, 2008 at 02:31 UTC | |
Re: What's wrong with this local() ?
by friedo (Prior) on Jan 30, 2008 at 02:33 UTC | |
Re: What's wrong with this local() ?
by Fletch (Bishop) on Jan 30, 2008 at 02:32 UTC | |
Re: What's wrong with this local() ?
by ikegami (Patriarch) on Jan 30, 2008 at 03:05 UTC | |
by tye (Sage) on Jan 30, 2008 at 08:14 UTC | |
Re: What's wrong with this local() ?
by saintmike (Vicar) on Jan 30, 2008 at 04:13 UTC | |
Re: What's wrong with this local() ?
by papidave (Pilgrim) on Jan 30, 2008 at 22:47 UTC | |
by Anonymous Monk on Jan 31, 2008 at 17:52 UTC | |
by ikegami (Patriarch) on Jan 31, 2008 at 18:37 UTC | |
by ikegami (Patriarch) on Jan 31, 2008 at 18:02 UTC |
Back to
Seekers of Perl Wisdom