in reply to really simple OO inheritance question

You're calling the method before all the class initialization is complete. Normally I'd put all the class definitions before any "executable code". It turns out, only one statement in your code above is not getting executed in time for your Cow->speak call, and that's the

our @ISA = qw(Animal);
statement. That is (unfortunately) "normal" code, not definitional. You can make it happen earlier by putting it in a begin block:
BEGIN { our @ISA = qw(Animal); }
but it's considered better practice (by some, anyway) to use a real pragmatic statement to define your inheritance relations:
use base 'Animal';

What is the sound of Windows? Is it not the sound of a wall upon which people have smashed their heads... all the way through?

Replies are listed 'Best First'.
Re^2: really simple OO inheritance question
by tomgracey (Scribe) on Jun 27, 2010 at 13:19 UTC

    Ah yes, it works now!

    That'll teach me for treating classes as subroutines... Looks like I've some way to go.

    Thanks greatly for putting me out of my misery!