in reply to closure question
On the other hand, if you changed your code to:
then the sub becomes a closure, and you get three distinct subroutines, each one refering to a distinct instance of $a.use strict; use Data::Dumper; my %x = map { my $a; $_ => [$_, sub {$a; shift;}] } qw(a b c); print Dumper(\%x);
|
|---|