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
In reply to Re: odd things with my and our
by hardburn
in thread odd things with my and our
by jcpunk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |