|
|
| No such thing as a small change | |
| PerlMonks |
Re: execute function with name passed as string parameterby shmem (Canon) |
| on May 05, 2011 at 12:05 UTC ( #903125=note: print w/ replies, xml ) | Need Help?? |
|
What the other monks said, but TIMTOWTDI. You can also store subroutine references in your hash and execute them.
You could also call the subroutine reference via &{$hash{choice}} - but be aware that there's a subtle difference:
That is, &sub, &$sub, &{gimme_a_subref()} and so on - without parens - pass the current @_ to the called subroutine. Of course, &{$hash{$choice}}() - with parens - passes an empty list.
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||