im trying to get a certain module to work
it is to be used by other modules
what this module does is overwrite the calling module's subroutines

im trying to emulate inheritance in a funky way, but thats not really important

basically my test module has a use statement and a sub declaration
eg.
package Test; use MyCoolModule; sub something { print 'hello, world'; } 1;
the MyCoolModule is to overwrite the 'something' subroutine to something else
eg:
sub import { *{'Test::something'} = sub { print 'greetings, earthlings!' }; }
but this doesnt work, because at the time i call the 'use', my 'something' sub isnt declared yet

is there any other way around this other than requiring it twice or putting the use statement at the end of my Test module?

thanks

updates

ok, perhaps i should be a bit more clear on what im intending to do

im writing a module to implement plugins
now what happens is, a (base) module has some subroutines
now another (child) module has some subroutines to overwrite the base ones, thus providing a generic plugin functionality

i believe that any module should be easy to plug in to, and thus shouldnt be altered in any way (except for including a 'use' statement at the top (hopefully))

i thought about it and inheritance just doesnt cut it
thinking about the 'inheritance' tree im trying to emulate, it'd look like a polynary tree stood on its head
hence the funky inheritance

i basically have it working, but my gripe is that the use Plugin '<plugin name>'; must be after the subs that are to be overwritten


In reply to Altering Package Subs and Running In To Problems by Bovine

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.