I donβt think too clearly right now and maybe I donβt notice anything simple. I thought about it for a while and searched, but I can no longer think of any reasonable search queries that will lead me to what I am looking for.
In short, I'm wondering how to do module inheritance, in how base.pm/parent.pm does this for object-oriented modules; Exporter-based modules only.
A hypothetical example of what I mean:
Here is our script. He originally downloaded Foo.pm and called baz (), but baz () has a terrible error (as we will see soon), so we now use Local / Patched / Foo.pm, which should fix the error. We do this because in this hypothetical case we cannot change Foo (this is the active cpan module) and it is huge (seriously).
#!/usr/bin/perl
Here is foo.pm. As you can see, it exports baz (), which calls qux, which has a terrible error, causing a malfunction. We want to keep baz and the rest of Foo.pm, although we donβt make tons of copy-paste, especially since they may change later, due to the fact that Foo is still under development.
package Foo; use parent 'Exporter'; our @EXPORT = qw( baz [... 100 more functions here ...] ); sub baz { qux(); } sub qux { print 1/0; }
Finally, since Foo.pm is used in MANY places, we do not want to use Sub :: Exporter, as this would mean copying the insert with the bind for all of these many places. Instead, we are trying to create a new module that acts and looks like Foo.pm, and actually loads 99% of its functionality with Foo.pm and just replaces the ugly qux sub with the best.
What follows is what this would look like if Foo.pm was object oriented:
package Local::Patched::Foo; use parent 'Foo'; sub qux { print 2; } 1;
Now this obviously will not work in our current case, since parent.pm just does not do this kind of thing.
Is there a simple and easy way to write Local / Patched / Foo.pm (using any applicable CPAN modules) so that it works without manually copying the Foo.pm function namespace?