Command line arguments with multiple values

arguments, command-line, perl

Solution

I think your problem could be `f{3}`. `f` is used for float arguments (real numbers). You should use the `s` specifier if you have strings as arguments. Regarding the number of arguments, the documentation says:

It is also possible to specify the minimal and maximal number of arguments an option takes. foo=s{2,4} indicates an option that takes at least two and at most 4 arguments. foo=s{,} indicates one or more values; foo:s{,} indicates zero or more option values.

Take into account hise note from docs and adjust to your needs.

Problem

I'm doing a perl script and I need to get multiple values from the command line. Example: ``` perl script.pl --arg1 op1 op2 op3 ``` I'm using Getopt::Long and I can get this to work: ``` perl script.pl --arg1 op1 --arg1 op2 --arg1 op3 ``` But I really need (want) the first option. I checked in their documentation and this is supposed to do what I want: ``` GetOptions('arg1=s{3}' => \@myArray); ``` http://search.cpan.org/~jv/Getopt-Long-2.38/lib/Getopt/Long.pm#Options_with_multiple_values But I'm getting this error: Error in option spec: "arg1=f{3}" Any ideas / solutions?

Original source