The simplest solution is that instead of exporting the function, use eval to compile a copy in the right package. Now SUPER will know what to do. If you do this then for sanity sake look at the bottom of perlsyn to find out how to create a comment that will make errors in your generated code state clearly where the code was compiled from. Trust me, when you are debugging a crash this will be much, much more useful than "eval 53".

If you don't want to go there, then you'll need to write a function that walks the symbol tree yourself. And you'll need to know inside the function what package it is installed in. This could be done with an import method that looks like:

sub import { my $package = shift; my $methodname = shift; my $dest = caller; my $method = sub { return super($package, "blah", @_; }; my $symbol = $dest . '::' . $methodname; { no strict 'refs'; *$symbol = $method; } }
where super is your function that looks at @ISA, and goes looking to find where ${"$package\::$method"}{CODE} is defined, then calls it.

Honestly this is so much work that I really would advise the eval solution here.


In reply to Re: SUPER or NEXT from imported methods by tilly
in thread SUPER or NEXT from imported methods by jsadusk

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.