in reply to Adding a number from scalar variable to array name

Use a hash of anonymous arrays instead:
my %store; foreach my $num ( 1..4 ) { $store{ "get$num" } = [ $num ]; }
--shoesaphone

Replies are listed 'Best First'.
Re^2: Adding a number from scalar variable to array name
by Anonymous Monk on Sep 08, 2006 at 19:05 UTC
    Maybe that will work, but I need those arrays later to create multiple querys from.. So for example. I created @array1, @array2 and @array3 names for my arrays based on the for loop. @array1 = (1,2,3); @array2 = (4,5,6); so later in my perl code I can run these queries: in my for loop (1..10 or whatever) Select * from table where id in (@array1); Select * from table where id in (@array2); Select * from table where id in (@array3); etc

      Using the hash of array references will work for you.

      Instead of @array1=(1,2,3) you say $hash{1}=[ 1,2,3 ]. Then, to use this as an array you would say "...where id in @{$hash{1}}..."