Check this out!

  def executeCode (code, input)  #  I'm just ignoring input for now.
    code = "begin\n" +
            code +
           "\nrescue Exception => error\n" +
           "puts error.inspect\n" +
           "end\n"
    strIO = StringIO.new
    strIO.instance_eval code
    strIO.string
  end

I don't fully understand this code... The StringIO parts.  Half of it is
from the ML, and half is me trying to figure out what StringIO is (god bless
irb!!!).

Well, it works great.  No namespace issues, no redirecting, and it even
catches errors!


So, now I just need some way to feed input into StringIO, I guess... so that
if did this:

  code = <<-END_CODE
    str1 = gets
    str2 = gets
    puts str1
    puts str2
  END_CODE

  input = "hello\n" + "hi\n"

  output = executeCode (code, input)

...I'd get back "hello\nhi\n".

Any ideas?

Chris