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?
Your code works for me, but it looks like that feature was only added to Getopt::Long recently (version 2.35), so you might have an old version of Getopt::Long. Run
perl -MGetopt::Long -le'print $Getopt::Long::VERSION;'
to see what version you have.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With