in reply to Re: Invoking a string reference to a anonymous subroutine
in thread Invoking a string reference to a anonymous subroutine

#--- dispatch table ... $self->$meth(666); ... #--- lex sym ref via eval ... $self->$meth(777);

Don't both of these approaches take the interpreter on a useless (if there is no '42' package/class) or potentially bugilicious (if there is such a package and it contains a  _whatever method) run time search through the  @ISA tree? Why use the  -> operator to pass an ordinary (i.e., non-class/object reference) parameter? Only
    #--- abstracted
    ...
    handle($handler)->($self,888);
avoids this possibly lengthy detour, but substitutes eval work at runtime.

Of course, I'm not sure how one would create a '42' package in the first place, but what if it had been  $self = 'Foo'; in your example?

Replies are listed 'Best First'.
Re^3: Invoking a string reference to a anonymous subroutine
by LanX (Saint) on Jan 14, 2014 at 22:53 UTC

      I see: the trick is the RHS of the  -> must be a code reference. Hmmm... I dunno...