in reply to Re^2: How to conditionally execute a subroutine defined as hash value
in thread How to conditionally execute a subroutine defined as hash value
You need to pass the parameters when you call the function, not when you store the reference.
See tye's References Quick Reference.
# Here you take the reference to the subroutine my $calls = { A => \&print_A, B => \&print_B, }; # Here you call the subroutine $calls->{ $test }->(\%config_A);
When taking the reference, you should never use parentheses.
Using Data::Dumper on %calls would show you what Perl stored in %calls.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: How to conditionally execute a subroutine defined as hash value
by Anonymous Monk on Apr 02, 2014 at 10:53 UTC | |
by Corion (Patriarch) on Apr 02, 2014 at 10:55 UTC | |
by Anonymous Monk on Apr 02, 2014 at 11:16 UTC | |
by AnomalousMonk (Archbishop) on Apr 02, 2014 at 17:52 UTC |