"Orion Hunter" <orion2480 / hotmail.com> wrote in message
> However, why does this not work?

I can answer this part. Please see "ri eval" output for more details:

     As of Ruby 1.8, local variables assigned within an eval are
     only available after the eval if they were defined at the outter
     scope before the eval executed. In this way eval has the same
     scoping rules as blocks.

> $>ruby -e 'str = "a = 2"; eval(str); puts a'
> -e:1: undefined local variable or method `a' for #<Object:0x124b00>
> (NameError)
>
> p.s.  If I do the equivalent in IRB, it remembers the variable name.

I don't know how irb manages to do it : some "binding" magic I guess.
Can experts shed some light please?

-- shanko