Well I'm not sure why you would want to do it that way, but it can be done...
${$arrayname}{$columns[0]} = $columns[1]; You may be better off with an array of hashes... my @data = (); while( my @columns = $cursor->fetchrow ) { my %tmp = () $tmp{$columns[0]} = $columns[1]; push @data, \%tmp; # push the hash on to the array } ....Then later... foreach my $item ( @data ) { # dereference and use as a hash again my %tmp = %{$item}; } I have always found that it is better to use references than building variable names on the fly... unless of course there is a good reason what they can't be done. Rob -----Original Message----- From: Andrew Koebrick [mailto:[EMAIL PROTECTED]] Sent: Monday, December 31, 2001 4:02 PM To: [EMAIL PROTECTED] Subject: Left side variable interpolation during associative array assignment? I am trying to build up associative arrays using a looping draw from a database. I would like to end up with one or more arrays(depending on number of elements in the @Dataset) named %sub0, %sub1, %sub2... and so on. I need to keep these arrays around for latter manipulation. What I have now is: $c=0; foreach (@Datasets){ my $SQL = "select year,value from data where trend like '%$Datasets[$c]%' order by year"; my $arrayname = "\$sub$c"; my $cursor = $dbh->prepare($SQL); $cursor->execute; while(@columns = $cursor->fetchrow){ $arrayname{$columns[0]} = $columns[1]; #FAILED LEFT SIDE INTERPOLATION } # end while assignment $c++; } However, what obviously is happening is that $arrayname{columns[0]} = $columns[1] is sticking the values into an array called "$arrayname" rather than interpolating back to "$sub0" (or "sub1"... depending on what loop we are in). I've tried various conbinations of quotation marks and eval statements to try to make this work with no luck. Can this be done? If not, is there a standard workaround? Many thanks for any assistance. Andrew Koebrick Web Coordinator/Librarian MN-Planning (Office of Strategic and Long Range Planning) 658 Cedar St., Suite 300 St. Paul, MN 55155 651-296-4156 phone 651-296-3698 fax www.mnplan.state.mn.us -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]