Robert Klemme
9/7/2007 10:53:00 AM
2007/9/7, Michael T. Richter <ttmrichter@gmail.com>:
>
> On Fri, 2007-07-09 at 14:17 +0900, Todd A. Jacobs wrote:
> 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?
>
>
> #test1.rb:
>
> @a = 5
> @b = 4
>
> require 'test2'
>
> p @a
> p @b
> p @c
> #----8<-----
>
> #test2.rb:
>
> @b = 3
> @c = 2
>
> $ ruby test1.rb
> 5
> 3
> 2
> $
>
> Or am I missing something?
Yes, you are missing the local variable bit. :-)
robert