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