Tolgar
asked on
How to pass n,1 number of variables to Perl where n is not known?
Hi,
I would like to pass multiple variables to perl. I used $ARGV[0] to capture the first input. However my function call will be like that:
perl mycode.pl 111111 222222 333333 444444 555555 'I am appending this to my field'
Now I don't know how many numbers I will have in the input. So this is unknown. And I will loop through for each of these numbers to append the string to a variable.
What I do is something like this which obviously does not work as expected:
I want to loop through the n number of times where n is the count of these numbers,let's say in this example 5 times, and append the last one to $ssc->{'solution'}
How can I do it?
Thanks,
I would like to pass multiple variables to perl. I used $ARGV[0] to capture the first input. However my function call will be like that:
perl mycode.pl 111111 222222 333333 444444 555555 'I am appending this to my field'
Now I don't know how many numbers I will have in the input. So this is unknown. And I will loop through for each of these numbers to append the string to a variable.
What I do is something like this which obviously does not work as expected:
foreach (@ARGV) {
$ssc->{'solution'} .= $ARGV[0];
}
I want to loop through the n number of times where n is the count of these numbers,let's say in this example 5 times, and append the last one to $ssc->{'solution'}
How can I do it?
Thanks,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
$ssc->{solution} = "@ARGV";
ASKER
Thanks,