John M. Dlugosz has asked for the wisdom of the Perl Monks concerning the following question:
indicate that the expression is a CODE(xxxxx) reference. Shouldn't it be a GLOB?print "what? ", $main::{'VERSION'}, "\n";
See perlmod under "Symbol Tables": "The value in each entry of the hash is what you are referring to when you use the *name typeglob notation"
Update: I'm thinking that this hash notation only works when such a symbol actually exists, as opposed to glob notation which autovivifies. Meanwhile, it can be "messed up" by assigning to it improperly.
Solution: Normally, assigning a ref to a glob will overwrite the proper slot. If the hash entry doesn't exist, it's not a glob, so assigning to it makes it that type, not a glob!
The docs imply that this hash syntax is equivilent to the * glob syntax. It's not. The glob syntax works for symbols that don't exist (yet), and the hash only shows existing entries and behaves exactly like a standard hash with respect to auto-vivification. It doesn't know it's supposed to be a glob.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: package symbol table syntax?
by Ovid (Cardinal) on Nov 05, 2002 at 05:45 UTC | |
Re: package symbol table syntax?
by broquaint (Abbot) on Nov 05, 2002 at 12:43 UTC | |
Re: package symbol table syntax?
by chromatic (Archbishop) on Nov 05, 2002 at 05:46 UTC |