I've been looking through Package::Stash::PP (the none PP version is used by Class::MOP::Package). I'm trying to understand how it works and stumbled upon this block inside sub add_symbol:
{
# using glob aliasing instead of Symbol::gensym, because otherwise,
# magic doesn't get applied properly.
# see <[email protected]> on p5p
local *__ANON__:: = $namespace;
no strict 'refs';
no warnings 'void';
no warnings 'once';
*{"__ANON__::$name"};
}
What is the effect of the block? It appears to not do anything since the anonymous typeglob assignment is local to the scope. I examined the symbol table and also used Devel::Peek::Dump(), but did not see the significance of the mentioned block of code.
I tried searching but had no success finding the mentioned ticket: <20120710063744.19360
Thanks Dave for that link. Although I do not understand entirely the significance of that block of code, the example in Dave's link sheds light on the problem.
Here is a brief test case showing the difference in: