|
|
| Perl: the Markov chain saw | |
| PerlMonks |
Re: eval('__PACKAGE__') is always main?!!!by ikegami (Pope) |
| on Dec 23, 2004 at 21:09 UTC ( #417210=note: print w/ replies, xml ) | Need Help?? |
|
The docs say "In the first form," eval EXPR, "the return value of EXPR is parsed and executed as if it were a little Perl program." Perl programs are put into main until a package statement is encountered, so the documentation is consistent with the behaviour (although an explicit statement about this behaviour would be favourable). Which means the following is wrong?
There's definitely a bug, since __PACKAGE__ does not agree with the function getting called. do EXPR is consistent with eval EXPR, as stated in do's docs:
Of course, eval EXPR is inconsistent with eval BLOCK which "parsed--and executed within the context of the current Perl program".
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||