Skip Menu |

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

Report information
The Basics
Id: 7566
Status: resolved
Priority: 0/
Queue: Getopt-Long

People
Owner: Nobody in particular
Requestors: 172842 [...] rt.noris.net
Cc:
AdminCc:

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



Subject: "no_getopt_compat" does not work
From the documentation to Getopt::Long (v 2.34): getopt_compat Allow "+" to start options. Default is enabled unless environment variable POSIXLY_CORRECT has been set, in which case "getopt_compat" is disabled. However, neither using "no_getopt_compat" nor setting the environment variable to a true value seems to work; GetOptions() still considers arguments beginning with a plus sign as options: $ perl -MGetopt::Long -MGetopt::Long -le 'print Getopt::Long->VERSION; Getopt::Long::Configure "no_getopt_compat"; $ENV{POSIXLY_CORRECT} = 1; GetOptions foo=>\$bar; print "@ARGV"' +test one two three 2.34 Unknown option: test one two three I've tested it with Perl 5.6.0 and 5.8.5. Regards, fany
From: Johan Vromans <jvromans [...] squirrel.nl>
Date: Mon, 6 Sep 2004 15:27:57 +0200
To: bug-Getopt-Long [...] rt.cpan.org
Subject: Re: [cpan #7566] "no_getopt_compat" does not work
RT-Send-Cc:
Show quoted text
> $ perl -MGetopt::Long -MGetopt::Long -le 'print Getopt::Long->VERSION; Getopt::Long::Configure "no_getopt_compat"; $ENV{POSIXLY_CORRECT} = 1; GetOptions foo=>\$bar; print "@ARGV"' +test one two three > 2.34 > Unknown option: test > one two three
Configure "no_getopt_compat" has no effect, you can only enable it. (Maybe I should give a warning.) For POSIXLY_CORRECT to be taken into account, it must be set _before_ Getopt::Long is loaded. For example: $ env POSIXLY_CORRECT=1 perl -MGetopt::Long -le \ 'print Getopt::Long->VERSION; GetOptions foo=>$bar; print "@ARGV"' \ +test one two three 2.32 +test one two three -- Johan
Date: Mon, 6 Sep 2004 16:41:56 +0200
To: entwicklung [...] noris.net
Subject: Re: [cpan #7566] "no_getopt_compat" does not work (entwicklung) [noris #172842]
CC: bug-Getopt-Long [...] rt.cpan.org
From: jvromans [...] squirrel.nl (Johan Vromans)
RT-Send-Cc:
[Quoting Martin H. Sluka, on September 6 2004, 16:31, in "Re: [cpan #7566] "no"] Show quoted text
> So in order to disable "+"-options (I have to, because I'm writing > a script which should accept phone numbers in international notation, > e.g. "+49-170-7935715", as command line arguments), do I either have > to do that (e.g. within a BEGIN block) or manipulate prefix_pattern, > or are there any "nicer" possibilities?
Use Getopt::Long::Configure "posix_default"; or use Getopt::Long qw(:config posix_default); Alternatively, explicitly manipulation of prefix_pattern would be a good option. Happy hacking! -- Johan