From: s@... (Stefan Schmiedl) Date: 2002-03-28T04:09:54+09:00 Subject: Re: Variable variables in Ruby? On Wed, 27 Mar 2002 19:49:33 +0100, Jonas Delfs wrote: > skrev i en meddelelse > news:PGEPJIFLPEPOHCKEEEIKGEFBDBAA.james@rubyxml.com... > >> > How does Ruby handle variable variables? >> > I want @submitVars to have the value of $_{value_of_some_variable} >> >> $_foobar = "Hello, world" >> x = "foo" >> y = "bar" >> >> baz = eval("$_#{x}#{y}") >> >> puts baz # prints Hello, world > > Thanks - but I know this one. I want to do it without eval() for security > reasons (and maybe speed?). The var with the variable-name is comming from > the user. If you worry about security in this context, I would recommend going for a hash with the names as keys. s.