On 3/19/07, Jm lists <[EMAIL PROTECTED]> 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!
Because he is adding behaviour to the method but still wants the old behaviour. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
