Hi Jm,
1. If you use $class->speak(@_), the programe will go to infineite
loop.
because of recursive call.
2. The example is to demostrate, how to call the method of a class
immediately
up in the class hirarchy.
Hope it helps
Madan
Jm lists wrote:
Hello,
Consider this script (coming from Randal's book):
{ package Animal;
sub speak {
my $class = shift;
print "a $class goes ", $class->sound, "!\n";
}
}
{ package Mouse;
@ISA = qw(Animal);
sub sound { "squeak" }
sub speak {
my $class = shift;
$class->SUPER::speak(@_); #***the SUPER*****
print "[but you can barely hear it!]\n";
}
}
Mouse->speak;
__END__
This can work.
My question is,why the SUPER is needed here?
Since we inherit the speak method from parent class Animal and declare
the @ISA to include that class.So why the statement without "SUPER"
can't work at all?Like:
$class->speak(@_);
Thanks!
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/