Perl: the Markov chain saw | |
PerlMonks |
Re: purpose of Super keywordby pajout (Curate) |
on Feb 10, 2010 at 22:20 UTC ( [id://822537]=note: print w/replies, xml ) | Need Help?? |
Consider following example: test.pl:
Aninal.pm:
Animal/Dog.pm:
Running test.pl will return:
When parent method (Animal::new in the example) does something important (it sets 'need_oxygen' for all animals), you can call it WITHOUT explicit hardcoding of the parent class, as was already noticed.
For instance, in Animal::Dog::Husky->some_method body, you can call some inherited method and you do not care if that method is written in Animal or in Animal::Dog class.
In Section
Seekers of Perl Wisdom
|
|