From: Erik Veenstra Date: 2007-09-07T19:50:12+09:00 Subject: Re: Equivalent of "source" in ruby? > Contrary to my expectations, if I have some variable > assignments in an external file, I can't simply call: > > load rcfile Load starts a new scope without reusing the local scope. Eval starts a new scope with reusing the local scope. So, use eval instead. But you should "define" the vars before loading them. gegroet, Erik V. - http://www.erikveen.dds.nl/ ---------------------------------------------------------------- $ cat test.rb a=nil b=nil eval(File.read("vars.rb")) # Or better: Thread.new{$SAFE=4 ; eval(File.read("vars.rb"), Module.new.instance_eval{binding})}.join p a p b ---------------------------------------------------------------- $ cat vars.rb a = 7 b = 8 ---------------------------------------------------------------- $ ruby test.rb 7 8 ----------------------------------------------------------------