Keep It Simple, Stupid | |
PerlMonks |
Re: Ask a Silly Question...by Util (Priest) |
on Feb 01, 2008 at 03:05 UTC ( [id://665506]=note: print w/replies, xml ) | Need Help?? |
Perl has a strict separation between "lexical" variables and "package" variables. Package vars live in the symbol table, can be declared with "our()" or "use vars qw()" (or just spring into existence when first used if "use strict vars" is not in effect), and can be remotely manipulated with things like Exporter or direct package references like "$Data::Dumper::Sortkeys=1". They always *exist* globally (although our() can control where they can be *referenced*). They are generally used only when you *need* some other package to manipulate your data remotely. Lexical vars are *not* accessible from the symbol table; they live in the "lexical PAD" that exists in every lexical block. They are never truly global; at best (worst?) they can be scoped to their entire declaring file. These are the vars that are always to be used, unless you have a specific need for a package var. So, in your three examples:
In Section
Seekers of Perl Wisdom
|
|