I have a script that should take some parameters, one of which is -i (input). I tried the following code to get the input parameters to an array:
use strict;
use warnings;
use Getopt::Long;
my @input = ();
my $help = '';
my $other = '';
GetOptions(
'help' => \$help,
'input=s{1,}' => \@input,
'other=s' => \$other
);
When I try to run it as ./my_script.pl -i param1 param2 -o aaa, I get the following:
Error in option spec: "input=s{1,}"
If I run it explicitly with perl like perl my_script.pl -i param1 param2 -o aaa, everything works smoothly. Is there a way to get these parameters into an array (without using @ARGV) without explicitly calling perl from the command line?
source
share