in reply to odd things with my and our
In library.pm, you declare two scalars that are stored in very different places by Perl. our declares a variable in the symbol table, while my declares a variable in the lexical pad. When you say $library::our, you're asking for the variable declared in the library package's symbol table. Likewise, $library::my gets at the symbol table, but since $my was declared as a lexical, there is no entry for it in the symbol table, so you get undef back (strict 'vars' is meaningless when accessing the symbol table).
Getting at the lexical pad is possible, but very difficult. This should be considered a feature.
----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer
: () { :|:& };:
Note: All code is untested, unless otherwise stated
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: odd things with my and our
by Anonymous Monk on Jan 25, 2004 at 05:04 UTC | |
by revdiablo (Prior) on Jan 25, 2004 at 09:48 UTC | |
|
Re: Re: odd things with my and our
by jweed (Chaplain) on Jan 25, 2004 at 07:25 UTC | |
by hardburn (Abbot) on Jan 25, 2004 at 14:12 UTC |