philippe44 has asked for the wisdom of the Perl Monks concerning the following question:
What happens is that a call to "top::new", calls "top::open" that calls "remote::request" as expected and then in 'sysreadline', the call to 'sysread' calls IO::Socket::INET::sysread, not 'top::sysread'. I thought in IO::Socket::INET::new, the object was blessed as a 'top' so 'sysread' would call the overloaded one#pseudo code in class 'top' sub new { my $class = shift; . . return open($class , $some_args); } sub open { my $class = shift; . . # I guess this is where the blessing of to $class happens ? my $sock = $class::SUPER->new($some_args); . . return $sock->request($some_args); } sub sysread { my $class = shift; . . $class::SUPER->read($var, 20); . . return $sock->request($some_args); } #pseudo code in class 'remote' sub sysreadline(*;$) { my ($handle, $maxnap) = @_; . $handle = qualify_to_ref($handle, caller()); sysread($handle, $var, 10); . } sub request { my $self = shift; . sysreadline($self, 10); . }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: inheritance problem
by hippo (Archbishop) on Oct 06, 2015 at 20:03 UTC | |
by philippe44 (Initiate) on Oct 07, 2015 at 01:59 UTC | |
by philippe44 (Initiate) on Oct 07, 2015 at 02:53 UTC | |
|
Re: inheritance problem
by GotToBTru (Prior) on Oct 06, 2015 at 19:56 UTC | |
|
Re: inheritance problem
by Anonymous Monk on Oct 07, 2015 at 01:15 UTC |