title: Get an input of array using Getoptions in perl
body: <p>I am trying to get create a file in perl using Getoptions and one of the input is an array. My code looks like this: </p>
  
  <pre><code>my $filename = 'grid.sh';
  my @job_name;
  my $output_file;
  my $testbench;
  my %opts = (
   'job_name' =&gt; \@job_name,
   'output' =&gt; \$output_file,
   'testbench' =&gt; \$testbench,
  );
  GetOptions(
    \%opts,
   'job_name=s',
  'output=s',
  'testbench=s'
  );
  open(my $fh, '&gt;', $filename) or die "Could not open";
  for (my $i=0; $i &lt;= 2; $i++) {
  print $fh "Job names are $job_name[$i]";
  }
     close $fh;
  </code></pre>
  
  <p>in my command line I am providing the input as </p>
  
  <pre><code>perl grip_script.pl "-job_name test -job_name test1 -job_name test2"
  </code></pre>
  
  <p>But the file is not giving the right data. Can you please tell me where I am going wrong? </p>
  
  <p>Thanks </p>