<> wrote in comp.lang.perl.misc:
> Is there an elegant way to tell other modules which are ISA some parent
> (either directly or indirectly) that they should be ISA something else
> instead?
Change their @ISA?
> For example, GD::Graph::lines, GD::Graph:
oints, and
> GD::Graph::linespoints.pm are all subclasses of GD::Graph::axestype.
>
> I want to subclass GD::Graph::axestype and override a method in it, and
> have that override exist for the three end-use modules. Currently the way
> I do it is to subclass each of the end-use modules individually:
I'd try this (untested):
Make your own less buggy Xho::axestype:
package Xho::axestype;
use base 'GD::Graph::axestype';
sub buggy_method {
# your non-buggy override
}
1;
Then, before using GD::Graph, but after its @ISA is set up, do something
like this:
for ( \ (
GD::Graph::lines::ISA,
GD::Graph:

oints::ISA,
GD::Graph::linespoints::ISA,
) ) {
$_ eq 'GD::Graph::linespoints' and $_ = 'Xho::linespoints' for @$_;
}
That should make the three modules use your improved version. The
@ISA-modifying code could go in a CHECK- or INIT-block to make sure[1]
everything is set up when it is called.
Anno
[1] Well, make it likely that everything is set up.
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.