FP::Weak - utilities to weaken references
use FP::Weak; sub foo { my $f; $f= sub { my ($n,$tot)=@_; $n < 100 ? &$f($n+1, $tot+$n) : $tot }; Weakened $f } is foo->(10, 0), 4905; # the subroutine returned from foo will not be leaked.
`Scalar::Util`'s `weaken`, unless one of the `with_..` development utils are used (or `$FP::Weak::weaken` is changed).
Calls `weaken <location>` after copying the reference, then returns the unweakened reference.
Protect <location> from being weakened by accessing elements of `@_`.
Optionally exported development utils:
No-ops. The idea is to prefix the weakening ops with 'no' to disable them.
Give a warning in addition to the weakening operation.
Give a warning with backtrace in addition to the weakening operation.
Within their dynamic scope, globally change `weaken` to one of the alternatives
Turn weakening on and off (unscoped, 'persistently').
This is alpha software! Read the status section in the package README or on the website.
To install FunctionalPerl, copy and paste the appropriate command in to your terminal.
cpanm
cpanm FunctionalPerl
CPAN shell
perl -MCPAN -e shell install FunctionalPerl
For more information on module installation, please visit the detailed CPAN module installation guide.