Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

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

by gaal (Parson)
on Dec 23, 2004 at 20:09 UTC ( [id://417199]=note: print w/replies, xml ) Need Help??


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

If that happened, I would call it a bug. But for me, it doesn't happen:

[roo@sike:~ 747] > perl -le 'package foo ;print eval('__PACKAGE__');' foo
(This is perl, v5.8.4 built for i386-linux-thread-multi. Debian.)

Replies are listed 'Best First'.
Re^2: eval('__PACKAGE__') is always main?!!!
by Corion (Patriarch) on Dec 23, 2004 at 20:11 UTC

    You made a classic shell quoting error - use double quotes for the internal quotes:

    perl -le 'package foo ;print eval("__PACKAGE__");'

    or, when your shell only gives you one flavour of quote, use Perls superior quoting facilities:

    perl -le 'package foo ;print eval(q(__PACKAGE__));'
      Eek, you're right; the unquoted __PACKAGE__ of course comes from the un-evaled compile-time pass, and hence does say "foo".

      I can't find mention of this behavior in the docs (eval is where I'd like it to be), so yes, I'd consider this a bug.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-24 20:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found