I am trying to pass Multiple Values to an Command line Argument as -cmd 'cp abc def' 'ls abd/def/ghi' etc ... and wanted to store these individually as an element of an array. I can take this to a string and use split function. i am trying to achieve the same using GetOptions. I am not sure of the reason it provides the size of the array. please help me with this.
use strict;
use warnings;
use Getopt::Long;
my( $cmd ,$pro, $dom );
GetOptions ( 'pro=s' => \$pro ,
'dom=s' => \$dom ,
'cmd=s@{1,}' => \$cmd );
print $pro."\n".@$cmd."\n".$dom."\n" ;
-->./abc.pl -pro JKFK -cmd 'ls abc/bcd/def' 'cp abn/cdf ads' -dom ABC
Expected:
JKFK
['ls abc/bcd/def','cp abn/cdf ads']
ABC
Actual Results :
JKFK
2
ABC
I am trying to get these system commands users provide and those commands directly go to DB tables. I am trying to store those system commands as it is as an element in array so that it would be easy to parse and Insert into DB table. Please help me put them into array.
Thanks.