Getoptions perl multi value function not working

You have the getoptions function below. The iifiles argument is optional, and provided that it can be from 1 to many. But when I ran this function, I got the error message โ€œError in spec optionโ€. Perl running on Solaris 10. Not sure if you need to provide multiple value options for iiles.

GetOptions( 'reportdate=s' => \$cmdParams{repDate} ,'switch=s' =>\$cmdParams{swi} ,'iiles:s{,}' => \@inputFileArray ,'h|?|help' => \$help ); 
+1
source share
2 answers

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

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

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

 GetOptions('somethings=i'=>\$some); @inputFileArray = @ARGV; 
+3
source

Perl running on Solaris 10. Not sure if a multi-value option should be provided for iiles.

Your problem is there. What version of Perl are you using? The last time I checked, the standard version of Perl on Solaris was 5.8.4. Now it can be up to 5.8.9. The problem is that the function you want by specifying the option as 'iiles:s{,}' => \@inputFileArray, probably does not exist in your version of Getopt::Long .

Run this command:

  $ perldoc Getopt::Long 

And find the line coordinates=f{2} . If you cannot find it, you do not have this option.

You can live without it. (There are more 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 Getopt::Long from CPAN. However, be careful to make sure that the download version works with your version of Perl. I recently noticed that some of the newer modules require features found in Perl post 5.10.

+2
source

Source: https://habr.com/ru/post/1412076/


All Articles