RosettaCodeData/Task/Closures-Value-capture/Perl/closures-value-capture.pl

3 lines
130 B
Perl
Raw Permalink Normal View History

2015-02-20 09:02:09 -05:00
my @f = map(sub { $_ * $_ }, 0 .. 9); # @f is an array of subs
print $f[$_](), "\n" for (0 .. 8); # call and print all but last