Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Error using Getopt::Long

by abhinav (Novice)
on Sep 27, 2007 at 09:13 UTC ( #641306=perlquestion: print w/replies, xml ) Need Help??

abhinav has asked for the wisdom of the Perl Monks concerning the following question:

Hi All,
I have this small code which is throwing an unexpected error.I am using Perl v5.8.3
use Getopt::Long; my @chk; GetOptions('nodelist=i{4}' => \@chk); print "@chk \n";
But when I am running the code,it is giving the following error -
root@c001n03 miscabhi# perl justtest1.pl --nodelist 1 2 3 4
Error in option spec: "nodelist=i{4}"

Replies are listed 'Best First'.
Re: Error using Getopt::Long
by andreas1234567 (Vicar) on Sep 27, 2007 at 09:42 UTC
    Works for me on Perl v5.8.5, Linux 2.6.9, Getopt::Long INST_VERSION 2.36, even when using strict and warnings:
    $ cat 641306.pl use strict; use warnings; use Getopt::Long; my @chk; GetOptions('nodelist=i{4}' => \@chk); print "@chk \n"; $ perl 641306.pl --nodelist 1 2 3 4 1 2 3 4
    What's you version of Getopt::Long?
    --
    Andreas
Re: Error using Getopt::Long
by almut (Canon) on Sep 27, 2007 at 09:55 UTC

    The "repeat" specification simply wasn't supported in the Getopt::Long version that came with Perl 5.8.3. Installing the recent version from 5.8.8 will make the problem go away, I suppose...

Re: Error using Getopt::Long
by rdfield (Priest) on Sep 27, 2007 at 09:54 UTC
    Which version of Getopt::Long are you using?
    perl -MGetopt::Long -e 'print $Getopt::Long::VERSION'
    In the three versions I have access to, the code you have doesn't work in 2.23 and 2.34 but does in 2.36. If your version is less than 2.36 you will have to upgrade it to use this functionality.

    rdfield

Re: Error using Getopt::Long
by jeanluca (Deacon) on Sep 27, 2007 at 09:44 UTC
    Your example works fine for me, maybe its because I'm using version 2.35 of Getopt::Long

    LuCa

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://641306]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2023-06-05 00:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you go to conferences?






    Results (22 votes). Check out past polls.

    Notices?