Subject: | Ambiguous value for... |
Date: | Wed, 20 Feb 2008 16:56:44 +0100 |
To: | bug-Getopt-Lucid [...] rt.cpan.org |
From: | "Torsten Link" <torstenlink [...] gmx.net> |
Hi David,
I had problems with the following Error Message the Getopt::Lucid module:
Ambiguous value for config could be option: /home/newuat5/nas/Abilit/newuat6/test_home/Data/tdg/testdatengenerator.conf
Here is the Command line I have used:
script.pl -c /home/newuat5/nas/Abilit/newuat6/test_home/Data/tdg/testdatengenerator.conf
This is the definition in my code:
my @specs = ( Param("config|c")->required(), Switch("help|h")->anycase(), );
my $opt;
eval { $opt = Getopt::Lucid->getopt( \@specs ); };
The Error is thrown because of the method '_find_arg' called from the method '_parameter'.
So far I understand the code, the method _find_arg checks if one of the keys of $self->{alias_hr} or $self->{alias_nocase} is in the possible value.
-------------------------------
your code:
-------------------------------
sub _find_arg {
my ($self, $arg) = @_;
$arg =~ s/^-*// unless $STRICT;
return $self->{alias_hr}{$arg} if exists $self->{alias_hr}{$arg};
for ( keys %{$self->{alias_nocase}} ) {
return $self->{alias_nocase}{$_} if $arg =~ /$_/i;
}
return undef;
}
-------------------------------
changed the line to:
-------------------------------
return $self->{alias_nocase}{$_} if $arg =~ /^$_$/i;
Now it is working, but I am not sure if this is right.
Here is the dump of $self:
-------------------------------
bless({
alias_hr => { c => "config", config => "config", h => "help", help => "help" },
alias_nocase => { h => "help", help => "help" },
default => { config => "", help => 0 },
options => {},
parsed => [],
seen => { config => 1, help => 0 },
spec => {
config => bless({ canon => "config", name => "config|c", type => "parameter" }, "Getopt::Lucid::Spec"),
help => bless({ canon => "help", name => "help|h", nocase => 1, type => "switch" }, "Getopt::Lucid::Spec"),
},
strip => { config => "config", help => "help" },
target => [
"/home/newuat5/nas/Abilit/newuat6/test_home/Data/tdg/testdatengenerator.conf",
],
}, "Getopt::Lucid")
-------------------------------
with kind regards
Torsten Link