in reply to closure question

Your sub isn't really a closure, because it doesn't reference any lexical variables that will go out of scope. Thus, there is no need for Perl to allocate a separate subroutine each time.

On the other hand, if you changed your code to:

use strict; use Data::Dumper; my %x = map { my $a; $_ => [$_, sub {$a; shift;}] } qw(a b c); print Dumper(\%x);
then the sub becomes a closure, and you get three distinct subroutines, each one refering to a distinct instance of $a.