in reply to Package coderefs

The simplest way without modifying your code is:

Callback::do_callback(sub { $self->do_something() });

I might instead add a callback_method() function that takes the name of a method to call and constructs a callback:

sub callback_method { my ($method, $invocant) = splice( @_, 0, 2 ); $invocant->$method( @_ ); }

Replies are listed 'Best First'.
Re^2: Package coderefs
by moot (Chaplain) on Jan 20, 2005 at 00:55 UTC

    Ouch. I was trying to avoid closures also. I thought perhaps there was a more direct way.

    Thanks for the response, though.