elTriberium has asked for the wisdom of the Perl Monks concerning the following question:
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:
Then, later on call it with:my $tcid; GetOptions("tcid=s" => \$tcid); my @tcids = split(",", $tcid); my %dispatch_table; foreach my $tc (@tcids) { $dispatch_table{$tc} = sub {eval "tcid_$tc()"}, );
$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!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: "Dynamic" dispatch tables
by roboticus (Chancellor) on Apr 29, 2011 at 18:12 UTC | |
Re: "Dynamic" dispatch tables
by mr_mischief (Monsignor) on Apr 29, 2011 at 18:14 UTC | |
by elTriberium (Friar) on Apr 29, 2011 at 18:20 UTC | |
by mr_mischief (Monsignor) on Apr 29, 2011 at 18:23 UTC | |
by elTriberium (Friar) on Apr 29, 2011 at 18:27 UTC | |
Re: "Dynamic" dispatch tables
by Tanktalus (Canon) on Apr 29, 2011 at 20:14 UTC | |
by chromatic (Archbishop) on Apr 29, 2011 at 21:06 UTC | |
by sundialsvc4 (Abbot) on Apr 29, 2011 at 22:41 UTC | |
by elTriberium (Friar) on Apr 29, 2011 at 20:26 UTC | |
by Tanktalus (Canon) on Apr 29, 2011 at 20:55 UTC | |
by elTriberium (Friar) on Apr 29, 2011 at 21:02 UTC |