- or download this
use Animal;
use Cow;
...
Cow->speak;
Horse->speak;
Sheep->speak;
- or download this
package Animal;
...
{
die "'You have to define sound() in a subclass' found";
}
- or download this
package Cow;
...
our @ISA = qw(Animal);
sub sound { "moooo" }
- or download this
package Sheep;
...
our @ISA = qw(Animal);
sub sound { "baaaah" }
- or download this
package Horse;
...
our @ISA = qw(Animal);
sub sound { "neigh" }
- or download this
a Cow goes moooo!
a Horse goes neigh!
a Sheep goes baaaah!