Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: eval('__PACKAGE__') is always main?!!!

by hossman (Prior)
on Dec 23, 2004 at 20:14 UTC ( #417202=note: print w/ replies, xml ) Need Help??


in reply to eval('__PACKAGE__') is always main?!!!

this is odd...

hal:~> cat test.pl package foo ; print eval('__PACKAGE__'); hal:~> perl -l test.pl main hal:~> perl -le 'package foo ;print eval('__PACKAGE__');' foo

Update: d'oh! ... that's what i get for trusting someone else's test case without looking at it closely.

what makes the -e version "work" is definitely the quotes, perl is seeing it as...

package foo ;print eval(__PACKAGE__);

...in which case the __PACKAGE__ gets interpolated before the eval.


Comment on Re: eval('__PACKAGE__') is always main?!!!
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://417202]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2015-07-04 14:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (60 votes), past polls