2
votes

Have the below getoptions function. iifiles argument is optional and it can be 1 to many if provided. But when i run this function getting an error message "Error in option spec". Perl running on solaris 10. Not sure what multiple values option for iiles needs to be provided.

GetOptions( 'reportdate=s' => \$cmdParams{repDate}
                   ,'switch=s' =>\$cmdParams{swi}
                   ,'iiles:s{,}' => \@inputFileArray
                   ,'h|?|help'  => \$help
                   );
2
Judging from the answers, you might need to run perl -MGetopt::Std -e 'print "$Getopt::Std::VERSION\n"' and compare that with the current versions. You can probably find the old documentation on CPAN, but perldoc Getopt::Std should also work. - Jonathan Leffler

2 Answers

3
votes

It looks like your Getopt::Long version does not support repeat specifiers. You can update it, or use a comma separated list for example:

GetOptions('iiles:s' => \$fileList);
@inputFileArray = split(/,/, $fileList);

alternatively, use the rest of the arguments in @ARGV for the list after parsing:

GetOptions('somethings=i'=>\$some);
@inputFileArray = @ARGV;
2
votes

Perl running on solaris 10. Not sure what multiple values option for iiles needs to be provided.

There's your problem. What version of Perl are you running? Last time I checked, the standard version of Perl on Solaris was 5.8.4. It might be up to 5.8.9 now. The problem is that the feature you want, specifying the option as 'iiles:s{,}' => \@inputFileArray, probably isn't there in your version of Getopt::Long.

Run this command:

 $ perldoc Getopt::Long

And look for the string coordinates=f{2}. If you can't find it, you don't have that option.

You can live without it. (There are still ways to specify multiple values), or you can try the Sun Freeware Site and see if they have a later version of Perl, or you can download the latest version of Getopt::Long from CPAN. However, be careful to make sure that the version you download works with your version of Perl. I've recently noticed that some of the newer modules require features that are found in Perl post 5.10.