more useful options | |
PerlMonks |
package symbol table syntax?by John M. Dlugosz (Monsignor) |
on Nov 05, 2002 at 04:57 UTC ( [id://210384]=perlquestion: print w/replies, xml ) | Need Help?? |
John M. Dlugosz has asked for the wisdom of the Perl Monks concerning the following question:
Why does the following:
indicate that the expression is a CODE(xxxxx) reference. Shouldn't it be a GLOB? 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.
Back to
Seekers of Perl Wisdom
|
|