Hi...

I've been going through Learning Perl Objs, Ref & Mods and I'm having
a some trouble with method invocation. The example codes below:

{
        package Animal;
        sub speak{
                my $class = shift;
                print "a $class goes ", $class->sound, "!\n";
        }
}

{
        package Horse;
        @ISA = qw(Animal);
        sub sound{
                "neigh";
        }
}

Horse->speak;

I understand that the class Horse would start looking for the method
speak in the Horse package and then move upto Animal. Once the method
speak is found in Animal, perl invokes the method
Animal::speak("Horse") and moves back to Horse for the sound method.

What I'm having trouble understanding is how $class is passed the
argument "Horse" when I don't explicitly pass Horse as a parameter to
speak.

Thanks, Dean


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to