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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^7: Creating dispatch table with variable in function name
by AnomalousMonk (Archbishop) on Nov 22, 2017 at 17:43 UTC | |
by Mr. Muskrat (Canon) on Nov 22, 2017 at 17:48 UTC | |
by AnomalousMonk (Archbishop) on Nov 22, 2017 at 18:01 UTC | |
by Mr. Muskrat (Canon) on Nov 22, 2017 at 18:57 UTC |