| [reply] [d/l] |
I think it's just there to look pretty. The leading package separator means it's in package main. The trailing package separator gets at the package stash. The typeglob dereference does point it at the typeglob. I'm not sure I'd call it symbolic, as a typeglob is sort of a special kind of hash...
All typeglobs do is associate the seven things that can be named with global names. Think of them as hashes that can only hold six keys -- SCALAR, ARRAY, HASH, CODE, IO, FORMAT. These are called slots, and you can get at the content of a glob by using the slot name as you would a hash key. The global (non-lexical) $foo, @foo, %foo, *foo, and &foo can all live within the typeglob *foo. Internally, anything that tries to use something with the name 'foo' will be resolved to use one of those things. Perl grabs the appropriate glob (resolving package names as necessary), then grabs the requested item from the appropriate glob slot.
Again, these are all things that have global and not lexical names.
You can copy typeglobs and assign to them. If you assign it a reference to something, it'll automatically populate (or overwrite) the appropriate slot. That's how Exporter works:
*{$package . '::mynewsub'} = \&mynewsub;
| [reply] [d/l] |
Is there a benefit to using this method over assigning the subref to a glob?
Being right, does not endow the right to be rude; politeness costs nothing. Being unknowing, is not the same as being stupid. Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence. Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.
| [reply] |
| [reply] [d/l] |
Upon further reflection, I think that having to put "no strict 'refs';" is actually a good thing. Without it, you don't have the HERE BE MONSTERS! warning that "no strict 'refs';" or "no warnings 'redefine';" provides. You're just doing hash manipulations which don't look like they're creating new subroutines in global-land. That's not very self-documenting ...
Being right, does not endow the right to be rude; politeness costs nothing. Being unknowing, is not the same as being stupid. Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence. Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.
| [reply] |