I am using an array to set values for a select lists in HTML. I have 10 select lists that are being passed the array called "@subtotaloptions_avail" or "@subtotaloptions_sel" with a 1-10 at the end of the array.
I am looping through available options and adding them to the array, however, I want to change the name of the array within the loop.
Here is an example of what I want to do, but it is giving me errors.
Could you please help by telling me how to change the name of the array within the loop?
Thanks!
I know that the problem is with these lines of code:
@subtotaloptions_avail$z
and
@subtotaloptions_sel$z
what I want is:
@subtotaloptions_sel2
@subtotaloptions_sel3
@subtotaloptions_sel4
etc.
I am looping through available options and adding them to the array, however, I want to change the name of the array within the loop.
Here is an example of what I want to do, but it is giving me errors.
Could you please help by telling me how to change the name of the array within the loop?
Thanks!
Code:
my $z=2;
for ($z <= 10){
# Set up the selected options for the custom fields.
foreach my $selection (@selections2) {
if ($listv[$i] eq $selection) {
$found = 1;
}
}
if ($found ne 1) {
push(@subtotaloptions_avail$z, "$listk[$i]:$listv[$i]" );
} else {
push(@subtotaloptions_sel$z, "$listk[$i]:$listv[$i]" );
}
$found = 0;
$z++
}
I know that the problem is with these lines of code:
@subtotaloptions_avail$z
and
@subtotaloptions_sel$z
what I want is:
@subtotaloptions_sel2
@subtotaloptions_sel3
@subtotaloptions_sel4
etc.