How09 has asked for the wisdom of the Perl Monks concerning the following question:
{ package Animal; sub sound { "WOOOAAARRRR" } sub speak { my $class = shift; print "a $class goes ", $class->sound, "!\n"; } } { package Horse; @Horse::ISA = qw(Animal); sub sound { "neigh" } sub p1 { print "p1: ". shift() ."\n"; } } Horse->speak(); # ok, works as expected Horse::p1("Horse"); # ok, prints "Horse" Horse::speak("Horse"); # Message: # "Undefined subroutine &Horse::speak called.. +." # So, the inheritance mechanism does not work +for this?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Inheritance via class::derived_method Question
by ikegami (Patriarch) on Nov 18, 2010 at 18:33 UTC | |
|
Re: Inheritance via class::derived_method Question
by AnomalousMonk (Archbishop) on Nov 18, 2010 at 22:03 UTC | |
by ikegami (Patriarch) on Nov 18, 2010 at 22:55 UTC | |
by How09 (Novice) on Nov 20, 2010 at 06:26 UTC | |
by ikegami (Patriarch) on Nov 22, 2010 at 17:31 UTC |