Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Packages, scope, and lexical variables

by merlyn (Sage)
on Mar 08, 2005 at 13:55 UTC ( [id://437551]=note: print w/replies, xml ) Need Help??


in reply to Packages, scope, and lexical variables

Everything you say is "by design" and "documented".

Packages are a way to politely separate the global symbol table. Lexicals were introduced later in Perl history to have more traditional "private" variables.

Because packages are global, there are no restrictions from any part of the code pushing to or pulling from any part of the global symbol table. Think of a package declaration as "in this area of this file, I don't have to type that silly package name in front of all my global names: Perl is doing it for me!". That's all it's doing, but if you spell out a package name explicitly, you're just doing the typing yourself.

I have a column on the relationship of my, our, packages, and lexicals, and my Alpaca book also goes into the subject in greater depth.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

  • Comment on Re: Packages, scope, and lexical variables

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (2)
As of 2024-04-24 14:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found