Class->method(@args)
attempts to invoke the subroutine Class::method as:
Class::method("Class", @args);
(If the subroutine can't be found, inheritance kicks
in, but you'll learn about that later.) This means
that you get the class name as the first parameter or the only
parameter, if no arguments are given. You can rewrite the
Sheep speaking subroutine as:
sub Sheep::speak {
my $class = shift;
print "a $class goes baaaah!\n";
}
The other two animals come out similarly:
sub Cow::speak {
my $class = shift;
print "a $class goes moooo!\n";
}
sub Horse::speak {
my $class = shift;
print "a $class goes neigh!\n";
}