use Animal; use Cow; use Horse; use Sheep; Cow->speak; Horse->speak; Sheep->speak; #### package Animal; use 5.006; use strict; use warnings; sub speak { my $class = shift; print "a $class goes ", $class->sound, "!\n"; } sub sound { die "'You have to define sound() in a subclass' found"; } #### package Cow; use 5.006; use strict; use warnings; use Animal; our @ISA = qw(Animal); sub sound { "moooo" } #### package Sheep; use 5.006; use strict; use warnings; use Animal; our @ISA = qw(Animal); sub sound { "baaaah" } #### package Horse; use 5.006; use strict; use warnings; use Animal; our @ISA = qw(Animal); sub sound { "neigh" } #### a Cow goes moooo! a Horse goes neigh! a Sheep goes baaaah!