Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: Autoloading and anonymous subs

by haoess (Curate)
on Jun 27, 2007 at 22:58 UTC ( #623767=note: print w/replies, xml ) Need Help??


in reply to Re: Autoloading and anonymous subs
in thread Autoloading and anonymous subs

And it's always the main package:

package Foo; sub AUTOLOAD { __PACKAGE__ } print $foo->(); package main; sub AUTOLOAD { __PACKAGE__ } __END__ main

I just can't find the documentation for this behaviour.

-- Frank

Replies are listed 'Best First'.
Re^3: Autoloading and anonymous subs
by shmem (Chancellor) on Jun 27, 2007 at 23:12 UTC
    You are calling an undefined coderef. This coderef (which isn't, being just nothing, or not existing) has no association with any package, albeit the variable holding "that nothingness" (if nothing can be something) has. Now, how should perl resolve that sensibly? There's no package, there's no code, there's no sub. Hence the default package (main), and as last resort, AUTOLOAD.

    The documentation is implicit in perlsub, perlref, ...

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://623767]
help
Chatterbox?
[LanX]: what is EOF POD?
[LanX]: POD and DATA don't interfere in any way, you can mix freely
[LanX]: you can even read pod from <DATA> if that's your question
[LanX]: or maybe that's your problem ? :)

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (13)
As of 2017-10-18 20:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (250 votes). Check out past polls.

    Notices?