package Animal; #parent class, in file lib/Animal.pm sub new { return bless {}, shift; } sub sound { die "cannot call this method on class '".ref(shift)."'"; } sub output_sound { my ($self, $what) = @_; print $what."\n"; } 1; package Animal::Dog; #desc. of Animal, lib/Animal/Dog.pm use base 'Animal'; sub sound { my ($self) = @_; $self->output_sound("haf"); } 1; package Animal::Dog::Sheepdog; #desc. of Dog #lib/Animal/Dog/Sheepdog.pm use base 'Animal::Dog'; sub guard { my ($self, $flock) = @_; #do something } 1; package Animal::Pig; #other descendant use base 'Animal'; sub sound { my ($self) = @_; $self->output_sound("khro"); } 1;