in reply to Re^2: Dereferencing a reference to a typeglob? [Postfix Dereference Syntax]
in thread Dereferencing a reference to a typeglob?
This code doesn't do what you think it does.
*a is always addressing the typeglob of the global symbol(s) named a , i.e. &a, $a, @a, %a the filehandle a and the format a .
( see here for how to use the clearer {SLOT} syntax.)
Maybe this code example makes it clearer:
DB<104> $a=42; my $a=666; my $ra=\*a; print $$$ra 42
Best think of the STASH (= Symbol Table Hash) as a Hash of Hashes, where the second level "hash" is a special structure called "glob" which always has exactly 6 fixed entries, which are either undef or a reference.
Lexicals use a totally different mechanism in the so called "Pad" and can't be addressed with * because there is nothing like a "lexical glob" unifying all lexical symbols.
If you use PadWalker to introspect pads you'll see that $x', '%x', '@x listed as separate top level symbols.
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!
|
|---|