perlquestion
elTriberium
Hi,
<p>
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.
</p><p>
Here's the basic idea:
</p>
<code>
my $tcid;
GetOptions("tcid=s" => \$tcid);
my @tcids = split(",", $tcid);
my %dispatch_table;
foreach my $tc (@tcids) {
$dispatch_table{$tc} = sub {eval "tcid_$tc()"},
);
</code>
Then, later on call it with:
<code>
$dispatch_table{$tc}->();
</code>
<p>
It's basically a big test file, which supports running individual test case ids, which can be passed in through the command line.
</p>
<p>
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.
</p>
Thanks!