|Problems? Is your data what you think it is?|
Creating "Lexical" Symbol Table Aliases (a la "use vars") From The Same Packageby OneTrueDabe (Acolyte)
|on May 08, 2014 at 16:50 UTC||Need Help??|
OneTrueDabe has asked for the
wisdom of the Perl Monks concerning the following question:
So I don't know if this belongs in SoPW or Meditations, but I stumbled across the following (what I would call) inconsistency, and wondered if anybody had an explanation...This does not work:
But this works fine:
Somewhat interestingly, this seems to work okay, too:
And this fails, as well:
I noticed that running "perl -MO=Deparse" on the last snippet, above, shows the symbol table manipulation being (*cough*) "optimized" (*cough*) thusly:
Perhaps that's why "strict" doesn't allow me to access the unqualified "@foo" directly? Because -- since it's not in a different package -- something, somewhere, isn't creating the corresponding lexical alias? *Shrug*
Finally, this is mostly the same as number 2, above, which also works, but in the fewest lines:
PS - Before you say "Just use 'our'" ...
Yes, I know. There's More Than One Way To Do It, and I'm MORE curious about the underlying question of why THIS way happens to fail.