Date: Fri, 29 Jun 2001 06:40:13 +0000 (UTC) From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin) Subject: Re: Naming a hash Message-Id: On Fri, 29 Jun 2001 14:27:09 +0800, Just in wrote: >Dear group, > >Suppose I was in a loop, and I wanted to push some values into a hash, but I >wanted the hash to have a different name for each iteration of the loop. i.e >how can I do this:- > >for ($a = 0; $a <= $#SomeArray; $a++) >{ > # do something to get data here > > $NewHash$a{$Var} = $Val; >} > >Obviously this wont work, and variations of the theme (that I have >attempted), dont work either. Instead of creating a new name with each iteration why not do something like: for( my $a = 0; $a <= $#some_array; $a++ ){ $hash{$a}{$var} = $val; } That way you don't need symbolic refs (which is what you're asking for even if you don't know it) which are evil. Cheers, Bernard -- perl -l54e's yyw q q tvmrx "h\ywx ersxliv zivp legoiv"qiy;y #a-zA-Z#d-gu-z# chefghijklmnopqrstuvwxyzcJab-def-uPwxyzc;s j j s u u s t t s r r s ppevalpereeteueje'