http://www.perlmonks.org?node_id=1080738


in reply to How to conditionally execute a subroutine defined as hash value

By adding parens, where you are attempting to store the address of your subs:      A => \&print_A(),, you are invoking the subs and then string the address of whatever is returned (the value 1 from print).

Try it this way:

sub print_A { print "\nA\n"; } sub print_B { print "\nB\n"; } $calls = { A=> \&print_A, B=> \&print_B };; $calls->{'A'}();; A

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.