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
|
|---|