On Thursday 03 January 2008 09:58:28 demerphq wrote: > And thinking about it more i think that was the whole point of the > weird call, Im guessing here, but probably this code isnt in a method > which means that he doesnt have access to SUPER so, he passes it into > can() which does. > > The following one liner demonstrates what the author of > Template::Timer was (correctly) doing. Note that it doesnt matter if > you define B::foo or not. > > $ perl -le'@B::ISA=qw(A); sub A::foo {print "in A::foo"} package B; > sub foo {print "in B::foo"} __PACKAGE__->can("SUPER::foo")->();' > in A::foo
Is that documented anywhere to work? I couldn't find it. In fact, it contradicts the documentation of can(): "can" checks if the object or class has a method called "METHOD". If it does then a reference to the sub is returned. If it does not then undef is returned. This includes methods inherited or imported by $obj, "CLASS", or "VAL". -- c