Hi - I'm green to Perl and I'm having problem understanding some inheritance behavior. Maybe it's obvious but I'm missing it (I used to be C++)
The class structure is the following: I have 2 classes built on top of each other, on top of Socket IO::Socket::INET ==> remote ==> top
'remote' defines 2 methods : 'open' and 'request'
'top' overloads 'open' and add methods 'new' that is called by the application actually using it and a method 'sysread' to overload default read
#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); . }
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
After that, all subsequent call to 'sysread' by the application with a 'top' object call the overloaded 'sysread'
(NB: my "real" problem is about a multiple inheritance, but I'm trying first to understand a basic behavior here, sorry)

In reply to inheritance problem by philippe44

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.