invoker - implicit invoker, sort of
use invoker; sub foo { my $self = shift; $->bar; # calls $self->bar; } use methods-invoker; method { $->bar # ditto }
The invoker pragma enables the $-> syntax for invoking methods on $self , inspired by Perl6's $.method invocation.
$->
$self
$.method
The module does not inject the $self variable for you. you are encouraged to use it in conjunction with self, selfvars, <Method::Signatures::Simple>, or other similar modules.
The following syntax works:
Regular hash access must still be written as $self->{attr} instead of $->{attr}.
$self->{attr}
$->{attr}
Internally, the module installs a parser hook to replace $-> ($- and the gt operator) with $--> (an invocation on the $- perlvar. It also injects an entersub hook to replace $- with $self.
$-
entersub
Chia-liang Kao <clkao@clkao.org> Audrey Tang <audreyt@audreyt.org>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
methods
To install invoker, copy and paste the appropriate command in to your terminal.
cpanm
cpanm invoker
CPAN shell
perl -MCPAN -e shell install invoker
For more information on module installation, please visit the detailed CPAN module installation guide.