On Thu, 08 Apr 2010 21:37:10 +0300, Shlomi Fish wrote:
> 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.
True, and I was torn, because I didn't know what he really needed, but it
sounded more like he needed a reference to the actual method than a
reference to an anonymous sub that called the method and passed $foo. IOW
I thought it more likely he needed a class method reference, given the
mention of attributes.pm
--
Peter Scott
http://www.perlmedic.com/ http://www.perldebugged.com/
http://www.informit.com/store/product.aspx?isbn=0137001274
http://www.oreillyschool.com/courses/perl1/
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/