Right, so you think of your packages as function suites.

package Functions::Base; use strict; use Exporter; our @ISA = qw(Exporter); our @EXPORT_OK = qw(func1 func2 func3); sub func1 { print "hello"; } sub func2 { print "kind"; } sub func3 { print "world"; } return 1;

and

package Functions::Alternate; use strict; use Exporter; use Functions::Base (@Functions::Base::EXPORT_OK); our @ISA = qw(Exporter); our @EXPORT_OK = (@Functions::Base::EXPORT_OK, qw (funcx funcy) ); # func1 is going to be replaced with our own no warnings 'redefine'; sub func1 { print "goodbye"; } # func2 is going to be replaced with our own sub func2 { Functions::Base::func2(); print "(haha)"; } use warnings 'redefine'; # func3 is reused from orig::functions unchanged # a couple new functions sub funcx { print "new x"; } sub funcy { print "new y"; } return 1;

and

package Functions; use strict; use Exporter; use Functions::Base qw(func1 func3); use Functions::Alternate qw(func2); our @ISA = qw(Exporter); our @EXPORT_OK = (func1 func2 func3); return 1;

so for subroutines

use strict; use Functions::Base qw(func1 func2 func3); func1; func2; func3; print "\n";

or

use strict; use Functions::Alternate qw(func1 func2 func3); func1; func2; func3; print "\n";

or

use strict; use Functions qw(func1 func2 func3); func1; func2; func3; print "\n";

I'd also note that by printing the functions which contain print statements, you are uselessly printing the functional return values, which will be 1. Thus, you are appending 1 to the end of your outputs for each call.


In reply to Re^3: Sharing and over-riding package functions by kennethk
in thread Sharing and over-riding package functions by ruzam

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.