in reply to initializing multiple arrays
Right off the top I suspect you're making this more complicated than it needs to be. For example, unless you have a real need for the intermediate reference, you could do this:
Taking that a step further (and this is making some assumptions since you don't show how @array_references is initialized) you might use a hash for your "master" list:my @array01 = @{$array_references[0]}; ... my @array10 = @{$array_references[9]};
Then you could simply use @{$array_references{array_01}}[$index] to access the elements. Taking that even further, you probably don't need to access as arrays at all but could be using reference notation instead: $array_references{array_01}->[$index].my %array_references; for ( 1 .. 10 ) { my $array_name = sprintf("array_%02d",$_); $array_references{$array_name} = []; }
Better names could also help. :)
Update: If in fact you have a need for array names to actually be @array_01, @array_02, etc, then storing them in a hash allows you to compute the name you need and access it more easily as a hash key.
|
|---|