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!
···
--
Chris Game
"Just because I don't care doesn't mean I don't understand."
-- Homer Simpson
but if someone could smuggle "system 'rm -rf /'" into data.rb you have
got a real problem.
regards,
Brian
···
On 30/07/05, Chris Game <chrisgame@example.net> 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!
------------------------------------------------------------------------
Loads and executes the Ruby program in the file _filename_. If the
filename does not resolve to an absolute path, the file is searched
for in the library directories listed in +$:+. If the optional
_wrap_ parameter is +true+, the loaded script will be executed
under an anonymous module, protecting the calling program's global
namespace. In no circumstance will any local variables in the <<<
loaded file be propagated to the loading environment. <<<
It gets executed before the $SAFE = 4 line that is getting
prepended. If there is malicious code in BEGIN {}, you lose.
Chris Game
Thanks - but does it always get executed before other lines which go
through the eval(..) statement in irb? It looks like irb executes
all lines in order.
···
--
Chris Game
"Chance favors only the prepared mind." -- Louis Pasteur