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:
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?$server->setcallback( data => \&gotdata, connect => \&connected, disconnect => \&disconnected, ) || die "Error setting callbacks: $@\n";
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; # [...] }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: coderef to an object method
by revdiablo (Prior) on Jul 21, 2004 at 05:29 UTC | |
by chromatic (Archbishop) on Jul 21, 2004 at 06:14 UTC | |
by Anonymous Monk on Aug 31, 2018 at 17:57 UTC | |
Re: coderef to an object method
by etcshadow (Priest) on Jul 21, 2004 at 05:33 UTC | |
by rinceWind (Monsignor) on Jul 21, 2004 at 09:48 UTC | |
Re: coderef to an object method
by ysth (Canon) on Jul 21, 2004 at 08:52 UTC | |
Re: coderef to an object method
by ambrus (Abbot) on Jul 21, 2004 at 09:04 UTC | |
by chromatic (Archbishop) on Jul 21, 2004 at 17:00 UTC | |
Re: coderef to an object method
by Your Mother (Archbishop) on Jul 21, 2004 at 18:54 UTC |
Back to
Seekers of Perl Wisdom