|go ahead... be a heretic|
Packages, scope, and lexical variablesby DigitalKitty (Parson)
|on Mar 08, 2005 at 07:05 UTC||Need Help??|
DigitalKitty has asked for the
wisdom of the Perl Monks concerning the following question:
I was recently experimenting with a few perl related topics and I felt as though I might benefit from some clarification. In the following code sample:
The output seems to indicate that a lexical variable (i.e. $var) is not associated with package level scope. I was able, however, to display the value of $var (15) by omitting the name of the initial package (Test). Only after using the package level 'qualifier' (our) was I able to obtain the value $var by prepending the package name.
Furthermore, there doesn't appear to be any safeguard that will prevent an interloper from creating subroutines within the namespace of neighboring (or distant) packages. Any feedback on these issues would be appreciated.