undef %h; for( qw[ the quick brown fox ] ){ my $closure = $_; $h{ $_ } = sub { print $closure; }; }; pp \%h; { brown => sub { "???" }, fox => sub { "???" }, quick => sub { "???" }, the => sub { "???" }, } $_='joe'; for my $key ( keys %h ) { $h{ $key }->(); };; the fox brown quick