On Mon, Aug 11, 2008 at 6:39 AM, Thind, Aman <aman.thind / lehman.com> wrote:
> Thanks for the reply!
>
> If I do eval(myaction) then it thinks all the words in the string are
> variables and complains:
>
> irb(main):002:0> myaction = 'perl #{ENV[HOME_SCRIPTS]}/myscript.pl
> -#{params[:date]}'
> => "perl \#{ENV[HOME_SCRIPTS]}/myscript.pl -\#{params[:date]}"
>
> irb(main):004:0> eval myaction
> NameError: undefined local variable or method `perl' for main:Object
>
> What I want is for all the known variables in the string to be expanded;
> the same effect that assignment with double quotes has.
>
> Please remember I know using double quotes in the assignment to myaction
> would solve the problem but I am doing this assignment only for
> illustration.
>
> I actually get the string from a db query so have to expand the
> variables after the assignment.
>
> Thanks,
> Aman
>

Sorry, I misunderstood your problem.

You could try %Q, like this
h = {}
h['MY_THING'] = 78 # hash just for the example

myaction = %Q{perl with whaterver you want and also #{h['MY_THING']}}
system myaction

Hope it helps.
-- 
Frantisek ZACEK (zacek_f) -- SRS 2008