[Omaha.pm] $self->SUPER::methodA();

Jay Hannah jhannah at omnihotels.com
Fri Feb 17 08:52:46 PST 2006


> if a class(CB) has methodA and the ISA (CA) has methodA, can
CB->methodA run and then call CA->methodA? Is that the SUPER:: notation?

Yup.

$ cat j.pl
package CA;
sub methodA {
   print "Hi. I'm the super/base/parent class.\n";
}

package CB;
use vars qw(@ISA);
@ISA = qw( CA );
sub new { return bless {}; }
sub methodA {
   my ($self) = @_;
   print "Hi. I'm the sub/derived/child class.\n";
   $self->SUPER::methodA();
}

package main;
my $obj = CB->new();
$obj->methodA;


$ perl j.pl
Hi. I'm the sub/derived/child class.
Hi. I'm the super/base/parent class.



More information about the Omaha-pm mailing list