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


in reply to Re^5: Creating dispatch table with variable in function name
in thread Creating dispatch table with variable in function name

Add this to the script:

sub AUTOLOAD { our $AUTOLOAD; warn sprintf "unknown subroutine '%s' called with params: '%s'\n", $ +AUTOLOAD, join "', '", @_; }

Output:
{ bar => sub { ... }, foo => sub { ... }, zot => sub { ... } }
unknown subroutine 'main::_x_zot' called with params: ''
hi from main::_x_foohi from main::_x_bar

Update: Yes, dynamically generated dispatch tables can cause problems if you aren't careful but that's true enough without them too. You can protect against most (all?) of the potential issues if you try. I'm not going to tell anything that they should or should not use dynamically generated dispatch tables in production. I do want to provide enough information for someone to be able to make that decision for themself.