in reply to Can an anonymous sub in a hash value know its key?

You could achieve the desired effect by wrapping a sub around accessing the values of the hash:
my $sr=sub{print shift() . qq(\n)}; # Subref for Hash my %h=(a=>$sr, b=>$sr); sub gh{ # Sub to access the hash value and call the sub.. my $p=shift; # Get the KEY requested # In real life, you would first check to see if it was a coderef.. &{$h{$p}}($p); # Call the anon sub, passing it the key # Returns the result of the call.. }; gh($_) for qw(a b b a); ### Prints a b b a

    ..."I don't know what the facts are but somebody's certainly going to sit down with him and find out what he knows that they may not know, and make sure he knows what they know that he may not know, and that's a good thing. I think it's a very constructive exchange," --Donald Rumsfeld