http://www.perlmonks.org?node_id=376160

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

I'm trying to write some modules that use Net::EasyTCP. There is a parent class that gets extended by several subclasses. The problem I'm running in to is with this code from EasyTCP:
$server->setcallback( data => \&gotdata, connect => \&connected, disconnect => \&disconnected, ) || die "Error setting callbacks: $@\n";
Before I used the OO-approach, I had no problem with this, but now I can't figure out how to do coderefs for OO versions of &gotdata, &connected, and &disconnected. The below is what I'd like to do, though, obviously the syntax is wrong. Is this do-able?
package ParentClass; # [...] sub init_server { my $self = shift; # [...] $self->{'server'}->setcallback( data => \&gotdata, # this coderef is wrong connect => \&connected, # and this disconnect => \&disconnected, # this too ) || die "Error setting callbacks: $@\n"; # [...] } sub gotdata { my $self = shift; # [...] } package ChildClass; use ParentClass; @ISA = qw(ParentClass); sub gotdata { my $self = shift; # [...] }