in reply to coderef to an object method
), you can just look up a coderef by method name for an object using can:$method = $self->{server}->getcallback("data"); $self->$method();
If a method isn't available for an object, can will return undef....setcallback( data => $self->can("gotdata"), connect => $self->can("connected"), disconnect => $self->can("disconnect") )
If the callbacks are expected to remember what object they belong (i.e. they are called like &{...getcallback("data")}()), use an anonymous sub:
...setcallback( data => sub { $obj->gotdata }, ...
|
|---|