CC: | Jeff Holt <jeff.holt [...] method-r.com> |
Subject: | Getopt::Long bug |
Date: | Mon, 14 Oct 2013 17:08:37 -0500 |
To: | bug-Getopt-Long [...] rt.cpan.org |
From: | Cary Millsap <cary.millsap [...] method-r.com> |
Here (below) is a test that shows Getopt::Long refusing to parse a valid
real number value provided as input. The code succeeds with '--num=0.1' but
fails with '--num=.1'. I am using GetOptions in my real code (same
behavior) but have used GetOptionsFromString in the test case to make the
test case easier to reproduce. This code succeeded on both inputs in
version 2.38, but it is broken now in 2.42.
use strict;
use warnings;
use Getopt::Long qw(GetOptionsFromString);
use Data::Dumper;
our %Opt = ( num => 0 );
our %Options = ( "num=f" => \$Opt{num} );
for (qw(0.1 .1)) { # both valid real number values
my $arg = "--num=$_";
$Opt{num} = undef;
GetOptionsFromString($arg, %Options);
print "arg is '$arg'\n", Dumper(\%Opt), "\n\n";
}
Here is my configuration info:
$ sudo ppm query Getopt-Long
+-------------+---------+-----------------------------------------------+------+
| name | version | abstract |
area |
+-------------+---------+-----------------------------------------------+------+
| Getopt-Long | 2.42 | Module to handle parsing command line options |
site |
| Getopt-Long | 2.38 | Extended processing of command line options |
perl |
+-------------+---------+-----------------------------------------------+------+
(2 packages installed matching 'Getopt-Long')
$ perl -v
This is perl 5, version 16, subversion 3 (v5.16.3) built for
darwin-thread-multi-2level
(with 1 registered patch, see perl -V for more detail)
$ uname -a
Darwin Cary-MacBook-Pro.local 12.5.0 Darwin Kernel Version 12.5.0: Sun Sep
29 13:33:47 PDT 2013; root:xnu-2050.48.12~1/RELEASE_X86_64 x86_64
Thank you for looking into it.
Cary Millsap
Method R Corporation
Author of *The Method R Guide to Mastering Oracle Trace
Data<http://amzn.to/173bpzg>
*