Skip Menu |

This queue is for tickets about the TimeDate CPAN distribution.

Report information
The Basics
Id: 72560
Status: open
Priority: 0/
Queue: TimeDate

People
Owner: Nobody in particular
Requestors: svgkraju [...] yahoo.com
Cc:
AdminCc:

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



Subject: Not able to restrict the number of arguments for an option with GetOptions in Getopt::Long
use strict; use warnings; use Getopt::Long; my @letters; my @words; GetOptions( "letters=s{2}" => \@letters, "words=s{,}" => \@words ); print "Letters: " . join(", ", @letters) . "\n"; print "Words: " . join(", ", @words) . "\n"; When I run this program I get the output as follows: perl getopts.pl --letters a --words he she it Letters: a, --words Words: --words is read as part of --letters arguments itself. I expect GetOptions to throw error message in this scenario. How to get this done. FYI.... Z:\examples\perl>perl -v This is perl 5, version 14, subversion 2 (v5.14.2) built for MSWin32-x86-multi-t hread (with 1 registered patch, see perl -V for more detail) Copyright 1987-2011, Larry Wall Binary build 1402 [295342] provided by ActiveState http://www.ActiveState.com Built Oct 7 2011 15:49:44 Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit. Complete documentation for Perl, including FAQ lists, should be found on this system using "man perl" or "perldoc perl". If you have access to the Internet, point your browser at http://www.perl.org/, the Perl Home Page.
From: svgkraju [...] yahoo.com
Raised this bug against wrong module. Please cancel this ticket. On Sun Nov 20 03:20:24 2011, svgkraju wrote: Show quoted text
> use strict; > use warnings; > > use Getopt::Long; > > my @letters; > my @words; > > GetOptions( > "letters=s{2}" => \@letters, > "words=s{,}" => \@words > ); > > print "Letters: " . join(", ", @letters) . "\n"; > print "Words: " . join(", ", @words) . "\n"; > > When I run this program I get the output as follows: > > perl getopts.pl --letters a --words he she it > Letters: a, --words > Words: > > --words is read as part of --letters arguments itself. I expect > GetOptions to throw error message in this scenario. How to get this done. > > > FYI.... > > Z:\examples\perl>perl -v > > This is perl 5, version 14, subversion 2 (v5.14.2) built for > MSWin32-x86-multi-t > hread > (with 1 registered patch, see perl -V for more detail) > > Copyright 1987-2011, Larry Wall > > Binary build 1402 [295342] provided by ActiveState > http://www.ActiveState.com > Built Oct 7 2011 15:49:44 > > Perl may be copied only under the terms of either the Artistic License > or the > GNU General Public License, which may be found in the Perl 5 source kit. > > Complete documentation for Perl, including FAQ lists, should be found on > this system using "man perl" or "perldoc perl". If you have access to the > Internet, point your browser at http://www.perl.org/, the Perl Home Page.