in reply to "Dynamic" dispatch tables
It's really pretty simple to use a dispatch table, so no module is really required. For example:
$ cat disp_tbl.pl #!/usr/bin/perl use strict; use warnings; use feature ':5.10'; sub foo { say "foobar" } sub bar { say "barbaz" } my %DT = ( foo=>\&foo, bar=>\&bar, quit=>sub { die "END!"; } ); say "Commands are foo, bar and quit\n"; while (<>) { chomp; if (exists $DT{$_}) { $DT{$_}(); } } $ perl disp_tbl.pl Commands are foo, bar and quit foo foobar bar barbaz quit END! at disp_tbl.pl line 9, <> line 3.
Update: By themselves, dispatch tables aren't a security concern. As long as the user isn't able to have perl (or the shell, database...) execute a string that the user enters, then everything is under the programs control.
Update: Ooops! mr_mischief mentioned that very thing as I was editing my node.
...roboticus
When your only tool is a hammer, all problems look like your thumb.
|
|---|