http://qs1969.pair.com?node_id=902050

elTriberium has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I want to dynamically call subroutines based on user input. I know that there are some security concerns with that, but in this scenario I think it should work.

Here's the basic idea:

my $tcid; GetOptions("tcid=s" => \$tcid); my @tcids = split(",", $tcid); my %dispatch_table; foreach my $tc (@tcids) { $dispatch_table{$tc} = sub {eval "tcid_$tc()"}, );
Then, later on call it with:
$dispatch_table{$tc}->();

It's basically a big test file, which supports running individual test case ids, which can be passed in through the command line.

My question now is: Since there are some security concerns for this and it requires some manual setup (creating the dispatch table, checking whether the sub exists at all, etc.) is there already a module which provides the required functionality? I thought that I can't be the first one ever having to run individual subs based on user input.

Thanks!