#--- 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?
In reply to Re^2: Invoking a string reference to a anonymous subroutine
by AnomalousMonk
in thread Invoking a string reference to a anonymous subroutine
by Superfox il Volpone
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |