Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^4: __PACKAGE__ in anonysub

by thpfft (Chaplain)
on Feb 19, 2005 at 20:52 UTC ( [id://432778]=note: print w/replies, xml ) Need Help??


in reply to Re^3: __PACKAGE__ in anonysub
in thread __PACKAGE__ in anonysub

Thank you! That won't work in my real situation, because I won't be calling a class method like that, but you made me realise that instead of __PACKAGE__, I just need to call ref $self, which will inherit properly. D'oh:

my $self = shift; my $factory_class=ref $self; *Foo::bar = sub { return $factory_class->instance; };

I definitely am creating a closure now, but I don't think it will matter: it's only a simple scalar that gets unnaturally prolonged.

Thanks.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-04-19 08:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found