jeanluca has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks

This is the situation:
Package Foo ; use base qw(SomeGeneralSubs) ; sub close { my $obj = shift ; # its all OO # do something specific .... # now call close from 'SomeGeneralSubs' ....? } package SomeGeneralSubs ; sub close { .. }
So, package Foo creates its own close, overriding close from SomeGeneralSubs. But after that it would like to call the close method from SomeGeneralSubs. How do I do this ?

Thanks a lot
Luca

Replies are listed 'Best First'.
Re: howto call an overridden sub
by salva (Canon) on Mar 27, 2006 at 09:29 UTC
    to call some method defined on any of the parent classes you can use the SUPER pseudo-package:
    Package Foo ; use base qw(SomeGeneralSubs) ; sub close { my $obj = shift ; # its all OO # do something specific .... # now call close from 'SomeGeneralSubs' $obj->SUPER::close(...) } package SomeGeneralSubs ; sub close { .. }
      Ok, I assume when you have multiple super classes, like
      use base qw(A B C)
      it will first try A, then B, etc!

      Luca
        yes, it does a deep search on the hierarchy tree, so it first looks for the method in A, then in A parents, then in B, etc.
Re: howto call an overridden sub
by davorg (Chancellor) on Mar 27, 2006 at 09:46 UTC