jettero has asked for the wisdom of the Perl Monks concerning the following question:

This seems like an easy one ... so it's been buggin' me. How do ya pass $object->function to a callback function? If it were in the same package, I would say:
$something->set_call_back( \&localfunction );
How do ya do it if it's ... from $object? I tried this:
$something->set_call_back( \$this->func ); # or $something->set_call_back( \&{ $this->func }); # and $something->set_call_back( \( $this->func ) );
I'll keep pluggin, but I bet it's really obvious...

Replies are listed 'Best First'.
Re: function ref
by merlyn (Sage) on Nov 13, 2000 at 17:57 UTC
Re: function ref
by Anonymous Monk on Nov 13, 2000 at 11:53 UTC
    If you know always know the package you could use $PACKAGE::{FUNC} which as I recall is a reference to funtion FUNC in PACKAGE. And if it uses the $this you are calling it with, pass that as the first argument.