From: Charles Steinman Date: 2005-08-19T05:06:15+09:00 Subject: Re: require question Gaston Garcia wrote: > Now my question is (I'm assuming) a very simple one: > > I'm trying to use the 'require' Kernel method. > > I save a file as 'my_string.rb' and it contains just this: > > my_string = 'hello world' > > On another ruby file saved as 'my_string_reader.rb' I write: > > require 'my_string' > > puts 'my_string' > > I thought that would output my 'hello world', but I get "undefined local > variable or method 'my_string' for main:Object (NameError) That's because require doesn't import local variables from a file. They stay local to the file they are in. If you make the variable a constant, global or instance variable, then it will work.