On Thursday 08 Apr 2010 17:19:39 Peter Scott wrote:
> On Wed, 07 Apr 2010 18:23:25 +0200, Eric Veith1 wrote:
> > this is probably going to be quick one. I know how to get an subroutine
> > reference under "normal" circumstances, but I don't know how to get one
> > from an object instance. Like:
> >
> > ---%<---
> > my $foo = My::Foo->new("bleh");
> >
> > # Calling the sub:
> > $foo->quux;
> >
> > # How would I get the reference to the sub just called, so that I could
> > do:
> > $quuxref->();
>
> $quuxref = $foo->can( 'quux' );
>
You still need to pass $foo to $quuxref, because ->can returns the subroutine
reference of the *method* - unqualified with the object reference.
> > I need this for the "attributes" pragma. :-)
>
> Uh, what are you really trying to do? There are helper modules that make
> using attributes much easier.
Yes, I'm wondering about it too.
Regards,
Shlomi Fish
--
-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/
Interview with Ben Collins-Sussman - http://shlom.in/sussman
Deletionists delete Wikipedia articles that they consider lame.
Chuck Norris deletes deletionists whom he considers lame.
Please reply to list if it's a mailing list post - http://shlom.in/reply .
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/