Also note that the C<Animal> classname is now hardwired into the
subroutine selection. This is a mess if someone maintains the code,
Also note that the C<Animal> classname is now hardwired into the
subroutine selection. This is a mess if someone maintains the code,
C<speak>. So, this is probably not the right way to go.
=head2 Starting the search from a different place
C<speak>. So, this is probably not the right way to go.
=head2 Starting the search from a different place
All we need is for a method to detect if it is being called on a class
or called on an instance. The most straightforward way is with the
C<ref> operator. This returns a string (the classname) when used on a
All we need is for a method to detect if it is being called on a class
or called on an instance. The most straightforward way is with the
C<ref> operator. This returns a string (the classname) when used on a