Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Scope, package, and 'my' variables

by ikegami (Patriarch)
on Jan 04, 2005 at 18:16 UTC ( [id://419341]=note: print w/replies, xml ) Need Help??


in reply to Scope, package, and 'my' variables

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);.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://419341]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2024-04-24 10:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found