in reply to How can I create an array that holds number of variables with values?
Use an array instead of multiple, distinct variables.my @var = (43, 60, 1..18); # Later... print $var[1], $var[14];
turnstep is right, you don't have to initialize all the variables to zero, just create them where you need them, giving a value at that time.
runrig's code (my @array = map {0} 0..19) works fine here, as well.
|
|---|