Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
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??

Help for this page

Select Code to Download


  1. or download this
    sub moo { print("moooooain\n"); }
    package cow;
    sub moo { print("moooOoooOOoooo\n"); }  # <--- prints this
    eval 'moo();';
    
  2. or download this
    > echo "print(__PACKAGE__, $/);" > script.pl
    > perl -e "package foo; do 'script.pl';"
    main
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (14)
As of 2014-09-23 16:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (232 votes), past polls