Hi all, I just work my way through "Learning Perl Objects, References & Modules". Now at one point, I am stuck: Randal introduces classes and methods in Chapter 8.
He gives the following example for overriding methods: { package Mouse @ISA = qw{Animal}; ... sub speak { my $class = shift; ... Animal::speak($class); ... } } Since there is a method speak in Mouse, it would override the parent's classes method Animal::speak if the latter were not called explicitly. But, as Randal points out, this forces Perl to look for speak in Animal and nowhere else - without the method invocation arrow, it cannot check @ISA for ancestor classes. So far, I get the point. But then he introduces the following solution: $class->Animal::speak(@_); Apart from the fact that @_ should be unnecessary here (or did I get something wrong), this should expand to: Mouse::Animal::speak("Mouse"); And when Perl does not find Animal::speak in Mouse, to: Animal::Animal::speak("Mouse"; and to higher classes if speak is not found there. Now my question: Does Perl reduce Animal::Animal::speak("Mouse") automatically to Animal::speak("Mouse"). And, if speak is not in Animal, how does it handle an expression like: LivingCreature::Animal::speak("Mouse"); It seems to me that the hard-coded package name we got rid of by using method calls just got back into our syntax. At the same time, I am sure the code works (have not tried it yet) and Perl does as it should. But how does this work? Thanks for any explanations, Jan -- There's no place like ~/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>