Personally, I would just set up aliases to the functions, and wrap that functionality in a bit of code. For example:
package ParentModule; use strict; sub base_foo {}; sub base_baz {}; sub import { my ($class,@routines) = @_; my $target = caller; # Install the requested routines in the target package for my $name (@routines) { no strict 'refs'; *{"$target\::$name"} = \&{"base_$name"}; }; }; 1;
And then in the child classes:
package ChildModule1; use strict; use ParentModule qw( foo bar ); package ChildModule2; use strict; use ParentModule qw( foo ); # Own implementation of bar() sub bar {...}; 1;
You can get fancier and provide hashes for name mappings.
In reply to Re: Forwarding functions to a different module
by Corion
in thread Forwarding functions to a different module
by rovf
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |