![]() |
|
Perl Monk, Perl Meditation | |
PerlMonks |
Re: goto superclass methodby Aristotle (Chancellor) |
on Dec 22, 2004 at 20:58 UTC ( #416903=note: print w/replies, xml ) | Need Help?? |
Unfortunately, this doesn't work in vanilla Perl:
This is an infinite loop, because it dispatches to UNIVERSAL::can with $_[ 0 ] as the first parameter. This means that adorning the call with SUPER:: doesn't make a difference here. And since the package for $_[ 0 ] is Bar, can() finds Bar::method, so round and round we go… But we can easily make this work. I came up with this before reading steves' reply, but it is just a cleaner, more polished version of that trick. Stick this somewhere in the code:
Tiny as it is, maybe this ought to be on CPAN? See replies. Makeshifts last the longest.
In Section
Seekers of Perl Wisdom
|
|