From: "Brian Schröder" Date: 2005-07-31T01:04:33+09:00 Subject: Re: Loading data (variables) On 30/07/05, Chris Game wrote: > Hi, I'm having some trouble loading dummy data into an irb session; > I can set require="somefile" to include Classes and methods from a > file, but the set of data assignments I have in another file I > cannot load - I get the 'NameError: undefined local variable...' > message when I try to load it and then examine the data afterwards. > The only way I can get the data into the irb session is by copy and > paste - I'm sure there must be a better way? > > I see there's some comment in the 'Pickaxe' about scope and local > variables from a loaded file on p.124 but I'm not at all clear as to > what to do to get them visible at the irb prompt! If you are not concerned about security, you could use bschroed@black:~/svn/projekte/ruby-things$ echo "test = 12" > data.rb bschroed@black:~/svn/projekte/ruby-things$ irb irb(main):001:0> eval(File.read('data.rb')) => 12 irb(main):002:0> test => 12 irb(main):003:0> but if someone could smuggle "system 'rm -rf /'" into data.rb you have got a real problem. regards, Brian -- http://ruby.brian-schroeder.de/ Stringed instrument chords: http://chordlist.brian-schroeder.de/