http://www.perlmonks.org?node_id=417192

gmpassos has asked for the wisdom of the Perl Monks concerning the following question:

Is that right?
package foo ; print eval('__PACKAGE__');
Output:
main
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.
"Creativity is the expression of liberty".