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