in reply to How to get variable evaluation in anonymous subroutines declaration
Make a copy of $parameter before binding to it:
sub make_print_ref { my ($parameter) = @_; return sub { print $parameter }; }; my $print_ref = make_print_ref(...);
I'm not sure if any of the Curry modules provide such a facility, but it isn't too hard to roll one yourself.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to get variable evaluation in anonymous subroutines declaration
by zorglups (Acolyte) on Jan 21, 2009 at 15:45 UTC |