in reply to Ref to an object instance method

All the above suggestions are fine, but if you want this really to be a feature of your objects, then you could add method currying features to a base class pretty easily ...

package Curryable; sub curry { my ($self, $method_name, @args) = @_; my $method = $self->can($method_name) || die "No $method_name meth +od found"; return sub { $self->$method(@args, @_) }; }
Then have your MIS_PrintStatus class inherit from Curryable and then all you need to do is this ...
my $handler = MIS_SAX_Parser->new($cb->curry('printit'));
And it will make sure to wrap up the method correctly for you. If you need some additional flexibility, you could also define a "right curry" method as well, which can come in quite handy. Note the reversal of the @args and @_ from the original curry.
sub rcurry { my ($self, $method_name, @args) = @_; my $method = $self->can($method_name) || die "No $method_name meth +od found"; return sub { $self->$method(@_, @args) }; }

-stvn

Replies are listed 'Best First'.
Re^2: Ref to an object instance method
by former33t (Scribe) on Dec 04, 2007 at 13:56 UTC
    Thanks much for the suggestion. I think this is more along the lines of what I was looking for. I'll work on implementing this today in the non-trivial example.