You need an explicit arrow operator to dereference (i.e. call) the subroutine.
$dispatch{$input}->()
(Update: First impressions are not always right. Thanks, Eric and Roy for catching my mistake.)
-xdg
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
In reply to Re: call subroutines via hash
by xdg
in thread call subroutines via hash
by fortesque
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |