From: Frantisek ZACEK Date: 2008-08-11T13:07:06+09:00 Subject: Re: Expanding variables in a string On Mon, Aug 11, 2008 at 6:00 AM, Thind, Aman wrote: > Hello, > > If I have a string containing variables, how can I expand them? > > I retrieve this string from a db so I cannot expand it at the time of > assignment. > > Eg: > > myaction = 'perl #{ENV['HOME_SCRIPTS']}/myscript.pl -#{params[:date]}' > > I want to be able to do: > > system(myaction) > > but for this I have to expand the vars inside the script first. > > Many Thanks, > Aman > > You mean you wish to execute in Ruby code you have in a string ? If that's wha you're looking for then eval is what you want. -- Frantisek ZACEK (zacek_f) -- SRS 2008