Quite a while ago I recall a thread in which it was noted that some Perl constructs results in a case where there isn't just a single "current package" (I searched but wasn't able to find it and have run out of time for now).
There are several different ways in which the "current package" can be felt. What __PACKAGE__ returns, how $x is interpretted (if there is no lexical $x in scope), where sub foo puts the subroutine, etc.
I think you've discovered this same problem. The outer package should either "leak" in or it should be reset to "main", but some constructs manage to only reset some of the "current package" items (when it should be either "all" or "none", not "some").
So, I think it is simply a bug in Perl, though a minor one.
In reply to Re^3: 'package' and 'do' (bug)
by tye
in thread 'package' and 'do'
by integral
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |