On 03/01/2008, Aristotle Pagaltzis <[EMAIL PROTECTED]> wrote: > * Andy Armstrong <[EMAIL PROTECTED]> [2008-01-03 18:25]: > > On 3 Jan 2008, at 16:55, Ovid wrote: > >> my $super = __PACKAGE__->can("SUPER::$sub") or die; > >> > >> This is OO code and that should actually read: > >> > >> my $super = __PACKAGE__->can($sub) or die; > > > > Should that be __PACKAGE__->SUPER::can($sub) ? > > No. That calls `can` from the superclass, but passes > `__PACKAGE__` as the invocant. Assuming that the subclass and the > superclass use the same inherited `can` method, the result is > therefore exactly the same. > > The correct incantation is > > my ( $super ) = grep { $_->can( $sub ) } @ISA;
I think the correct thing is what kicked off this conversation. my $sub= __PACKAGE__->can("SUPER::$sub"); Consider that with 5.10 its possible to use other method resolution rules than the one your snippet mimics. Yves -- perl -Mre=debug -e "/just|another|perl|hacker/"