From: "Erik Bågfors" Date: 2002-06-03T07:57:43+09:00 Subject: Re: $a = 5; $b = 'a'; print $$b On Mon, 2002-06-03 at 00:49, Philip Mak wrote: > Hello, > > I'm a seasoned Perl programmer trying to learn Ruby. > > Is there a way a variable name can be variable? Like, how would I > rewrite the following piece of Perl code in Ruby: > > $a = 5; > $b = 'a'; > print $$b; # should print 5 > a = 5 b = 'a' puts eval b > And can this be done with instance variables? I'm trying to do this: > > class Series > attr_accessor :sid, :handle, :name > def initialize(vals) > vals.each_key { |key| > @(key) = vals[key] # This doesn't work; syntax error I don't understand what you are trying to do here. /Erik -- Erik B�gfors | erik@bagfors.nu Supporter of free software | GSM +46 733 279 273 fingerprint: 6666 A85B 95D3 D26B 296B 6C60 4F32 2C0B 693D 6E32