in reply to How to get a reference to a superclass method?

Just:
my $super_meth = "SUPER::$meth"; $class->$super_meth(@_);

Replies are listed 'Best First'.
Re^2: How to get a reference to a superclass method?
by mcdave (Beadle) on Feb 10, 2012 at 18:00 UTC
    You're kidding, right??!!

    Of course, you're not kidding, because it works just fine. If someone could point me toward an explanation of why that works, I'd be very grateful.

    It seems that my "just type and hope Perl figures it out" approach was closest, but I couldn't get a permutation of $class->SUPER::$meth to compile.

        I guess what I was missing is that "SUPER" isn't as magical as I thought. I understand that $c->$m($x) is just $m($c, $x) but I was reading "SUPER" as somehow being associated to the class, not being part of the method. To abuse some notation, I was reading "$c->SUPER::get" as more like "($c->SUPER)::get" than like "$c->(SUPER::get)". That's not right; functions are the real things, and classes are the illusion.

        At http://perldoc.perl.org/perlobj.html#Method-Invocation it says "...you may use the SUPER pseudo-class to tell Perl to start looking for the method in the packages named in the current class's @ISA list." When I've read that in the past, I guess I thought "current" referred to "that thing just to the left of the '->'" but it means "the thing after 'package' up above".

        I feel like I understand better now.

Re^2: How to get a reference to a superclass method?
by Anonymous Monk on Feb 10, 2012 at 17:42 UTC
    If crack is whack, then meth is death!