Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Getopt-Lucid CPAN distribution.

Report information
The Basics
Id: 33462
Status: resolved
Priority: 0/
Queue: Getopt-Lucid

People
Owner: Nobody in particular
Requestors: torstenlink [...] gmx.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



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
Subject: Re: [rt.cpan.org #33462] Ambiguous value for...
Date: Wed, 20 Feb 2008 14:50:55 -0500
To: bug-Getopt-Lucid [...] rt.cpan.org
From: "David Golden" <dagolden [...] cpan.org>
Good catch - that looks right. I'll put together some test cases to confirm it. David On Wed, Feb 20, 2008 at 10:58 AM, Torsten Link via RT <bug-Getopt-Lucid@rt.cpan.org> wrote: Show quoted text
> > Wed Feb 20 10:58:15 2008: Request 33462 was acted upon. > Transaction: Ticket created by torstenlink@gmx.net > Queue: Getopt-Lucid > Subject: Ambiguous value for... > Broken in: (no value) > Severity: (no value) > Owner: Nobody > Requestors: torstenlink@gmx.net > Status: new > Ticket <URL: http://rt.cpan.org/Ticket/Display.html?id=33462 > > > > 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 > > >
Fixed in 0.17