Hi, I've got a class (say AA) that inherits from another class (say BB). I'ld like to 'proxy' all methods from AA to BB after I modified them slightly (take out 1 argument and process it, so if somebody calls AA->method , AA should catch this, and eventyally call BB->method. I've tried to use AUTOLOAD for this, but that catches undefined methods, not the methods that I want to override. Hope this makes sense (<monthy python>my brain hurts ....</monthy python>) , if not I'll add some code: test.pl:
use AA; AA->print("extrainfo","hi");
AA.pm:
package AA; use base 'BB'; sub AUTOLOAD { my ($self,$extrainfo,@args ) = @_; print "Via AA:\n"; print "extrainfo: $extrainfo \n"; $superfunk = "SUPER::$AUTOLOAD"; $self->$superfunk(@args); } 1;
BB.pm
package BB; sub print { my ($self,$arg) = @_; print "I'm BB saying: $arg\n"; } 1;
AA.pm
package AA;
if I run test.pl I'd like it to say
Via AA: extrainfo: extrainfo I'm BB saying: hi
but it says:
I'm BB saying: extrainfo

In reply to AUTOLOAD and inheritance by eXile

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.