Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When using multiple inheritance in Perl is there a way to indicate which SUPER function to use?

Tags:

perl

As per the title, I'm working on an awkward bit of code that makes use of multiple inheritance and requires that the two SUPER functions both be called. Is there a way of indicating to Perl which of the two parent classes I want to run the function from? Using $self->SUPER::foo($bar); only runs the first matching function in @ISA as per the documentation.

The following gives an idea of how the classes are inherited:

          [Base Class]
               |
 ----------------------------
 |                          |
[A]                        [B]
 |                          |
 ----------------------------
               |
              [C]
like image 411
rjzii Avatar asked Nov 30 '25 08:11

rjzii


1 Answers

Just specify it:

$self->A::foo($bar)

or

$self->B::foo($bar)

You may also want to look at mro.

like image 185
ysth Avatar answered Dec 03 '25 00:12

ysth



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!