From: Alan Chen Date: 2002-05-30T05:56:35+09:00 Subject: Re: object-name = content of a variable (migration from perl) On Thu, May 30, 2002 at 04:23:21AM +0900, Marc Rene Arns wrote: > I'm new to programing and ruby as well and I want to ?convert? a > PERL-Script, I've recently written into ruby. In the Perl-script, I > produced in a while-loop every time a different array who's name came > from a variable counting every time higher, something like that > > $i = 1; > while ($i < 10){ > @{$i} = (?several?, ?changing?, ?variables?); > $i = $i+1; > } > > so that I got a set of arrays @1, @2, and so on > > Now I want to do the same thing in ruby, but I found no way to do it. I think another poster mentioned one way to dynamically create your array names in ruby. As an alternative, is there any reason the data has to be stored in @1, @2, etc? Could you just as easily store the data in a hash: @data = Hash.new # {} works too 10.times { |i| @data[i] = [ ?several?, ?changing?, ?variables? ] } -- Alan Chen Digikata LLC http://digikata.com