R
Ronald Fischer
How do I evaluate a text file as a sequence of Ruby statements?
(For those who happen to know Perl: I would like to have an
equivalent of the Perl 'do FILENAME' feature).
For example, I have a file "foo" which contains the lines
abc=4
def=5
I would like to "evaluate" the file such that after this, the
variable abc is set to 4 and def is set to 5.
I tried the following:
eval(File.new("foo").read)
But after this, abc is still undefined. What am I doing wrong here?
Ronald
(For those who happen to know Perl: I would like to have an
equivalent of the Perl 'do FILENAME' feature).
For example, I have a file "foo" which contains the lines
abc=4
def=5
I would like to "evaluate" the file such that after this, the
variable abc is set to 4 and def is set to 5.
I tried the following:
eval(File.new("foo").read)
But after this, abc is still undefined. What am I doing wrong here?
Ronald