perl - Working with many variables in a for loop -


ok have alot of variables in numeric order. unfortunately not in array. need work on each variable , wondering smartest way so. i've read using variable in variable name dangerous, since can cause complications. thinking of below appreciate guidance :)

my $var10 $var20 $var30 ... $var300  (my $t = 10; $t < 301; $t++){$var$t ...} 

edit: let's wanted push these variable's array. how best proceed?

pull variables' values hash using

my %var; {   (1 .. 30) {     $n = $_ * 10;     $var{$n} = eval "\$var$n";   } } 

then can

for (1 .. 30) {   $t = $_ * 10;   $var{$t}... } 

or just

for $t (sort { $a <=> $b } keys %var) {   $var{$t}... } 

but don't again!


Comments