package replace::functions; BEGIN { # import the original functions, but not the ones # this package is going to replace use orig::functions qw(!/func1|func2/); use Exporter (); use vars qw(@ISA @EXPORT_OK); @ISA = qw(Exporter); # let the original functions be exported as well # as the new ones @EXPORT_OK = (@orig::functions::EXPORT_OK, qw(funcx funcy) ); } # func1 is going to be replaced with our own sub func1 { print "goodbye"; } # func2 is going to be replaced with our own sub func2 { orig::functions::func2(); print "(haha)"; } # func3 is reused from orig::functions unchanged # a couple new functions sub funcx { print "new x"; } sub funcy { print "new y"; }