in reply to Getopts::Long -- changing its behavior
Getopt::Long in this case is just letting you be flexible -- the '-' is a valid character in a string, so it lets you put it in there. What I've done in the past is set up a collection of regular expressions to validate the strings passed in. You can do this after argument processing, or during using anonymous subs.
This ain't pretty, but it'll work.
my %script_opts = (); GetOptions("foo=s" => sub { if ($_[1] =~ /^([^-]).*$/) { $script_opts{$_[0]} = $_[1];} } );
Documentation for the module is here.
|
|---|