=== code start ===
begin
DATA.each do |line|
var, expr, excess = line.chomp.split(/=/, 3)
var.strip!; expr.strip!
puts “expr=” + expr + “, expr.class=” +expr.class.to_s
puts “eval(expr)=” + eval(expr).to_s
end
rescue Exception => eMsg
puts "ERROR: " + eMsg
retry
end
END
a = 5**2 =# 25
b =date =# undefined local variable or method date' for main:Object c = y =# undefined local variable or methody’ for main:Object
c =date =# (ruby hangs; Ctrl-C kills it)
=== code end ===
This is the output: [email protected]:~$ ruby /tmp/tmp.rb
expr=5**2, expr.class=String
eval(expr)=25
expr=date, expr.class=String
ERROR: undefined local variable or method date' for main:Object ERROR: undefined methodstrip!’ for nil:NilClass
expr=y, expr.class=String
ERROR: undefined local variable or method y' for main:Object expr=date`, expr.class=String
eval(expr)=Sat Dec 16 22:01:37 EST 2006
Thanks for your results. I suspect you were running on Uni*. I was
running in SciTE over WindowsXP.
When I ran the program in a Command window, I saw what the problem is:
in Windows, the date command waits for keyboard input specifying a new
system date. That wasn’t apparent when I was running under SciTE.
So, all’s well in my Ruby sandbox.
Regards,
Richard
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.