Your skill will accomplish what the force of many cannot |
|
PerlMonks |
eval('__PACKAGE__') is always main?!!!by gmpassos (Priest) |
on Dec 23, 2004 at 19:19 UTC ( [id://417192]=perlquestion: print w/replies, xml ) | Need Help?? |
gmpassos has asked for the wisdom of the Perl Monks concerning the following question:
Is that right?
Output: The sense tell me that should be foo! I tested this on Perl 5.6.1 and 5.8.3 and the output is the same. Is that a bug or an odd behavior? UP: Note that the main idea is not how to get foo as value. The idea is that __PACKAGE__ will always point to main unless we define the package inside the eval like this: eval('package foo ; __PACKAGE__'). This is very odd, since any code evaluated will make references to the local pakcage and not main.
Graciliano M. P.
Back to
Seekers of Perl Wisdom
|
|