XP is just a number | |
PerlMonks |
Re: Scope, package, and 'my' variablesby ikegami (Patriarch) |
on Jan 04, 2005 at 18:16 UTC ( [id://419341]=note: print w/replies, xml ) | Need Help?? |
There's such thing as "a lexical (my var) in package 'aaa'", as implied. Lexicals are not package-scoped, they are block scoped. That's the whole idea behind them. All three of your $var variables are in the same block, which is why the second and third one hide the previous ones. Block scoping is determined by file and by curlies (and probably by some less obvious things), but not by packages. If you want package variables, use our $var or use vars qw($var);.
In Section
Seekers of Perl Wisdom
|
|