From: Robert Klemme Date: 2007-09-10T15:59:33+09:00 Subject: Re: Equivalent of "source" in ruby? 2007/9/7, Robert Klemme : > 2007/9/7, Todd A. Jacobs : > > Contrary to my expectations, if I have some variable assignments in an > > external file, I can't simply call: > > > > load rcfile > > > > to have it sourced. Instead, I found myself having to do this: > > > > IO.foreach(rcfile) do |line| > > eval line > > end > > > > which seems lame. Is there a better way? > > It is also unsafe - not only because of the eval but also because this > will give errors for expressions that span multiple lines. The easy > fix would be > > eval(File.read(rc_file)) > > But I'd rather resort to one of the other suggestions (namely using > local variables). That was intended to read "global" of course. Sorry for the noise. robert