gmpassos has asked for the wisdom of the Perl Monks concerning the following question:
Is that right?
Output:package foo ; print eval('__PACKAGE__');
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.main
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".
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: eval('__PACKAGE__') is always main?!!!
by ikegami (Patriarch) on Dec 23, 2004 at 21:09 UTC | |
by gaal (Parson) on Dec 24, 2004 at 07:01 UTC | |
Re: eval('__PACKAGE__') is always main?!!!
by MarkusLaker (Beadle) on Dec 23, 2004 at 20:13 UTC | |
Re: eval('__PACKAGE__') is always main?!!!
by Anonymous Monk on Dec 24, 2004 at 00:18 UTC | |
Re: eval('__PACKAGE__') is always main?!!!
by gaal (Parson) on Dec 23, 2004 at 20:09 UTC | |
by Corion (Patriarch) on Dec 23, 2004 at 20:11 UTC | |
by gaal (Parson) on Dec 23, 2004 at 20:21 UTC | |
Re: eval('__PACKAGE__') is always main?!!!
by hossman (Prior) on Dec 23, 2004 at 20:14 UTC |
Back to
Seekers of Perl Wisdom