Instead of attempting to create variables 'on the fly,' consider creating a hash of arrays (HoA) whose keys are array1 .. array5:
use strict; use warnings; my %hash; for my $i ( 1 .. 5 ) { for my $k ( 0 .. 4 ) { ${ $hash{ 'array' . $i } }[$k] = $i**$k; } } print "$_: @{ $hash{ $_ } }\n" for sort keys %hash;
Output:
array1: 1 1 1 1 1 array2: 1 2 4 8 16 array3: 1 3 9 27 81 array4: 1 4 16 64 256 array5: 1 5 25 125 625
Hope this helps!
In reply to Re: concatenate scalar with array name
by Kenosis
in thread concatenate scalar with array name
by iThunder
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |