Inexplicable "undefined local variable" error`


#1

This makes no sense to me, so…I could use a little help

In my main program I read in some ruby from an external file:

eval( File.read( “…/lib/setnet/Utilities.rb” ) )

I check a variable which should now be defined (by a line in that file),
using ruby-debug:

Breakpoint 1 at SN.rb:550
…/lib/setnet/SN.rb:550
pp menu_ut # <= my main program code about to execute, so menu_ut
better be there
(rdb:1) p defined? menu_ut
“local-variable” # <= looks good
(rdb:1) p menu_ut # <= this successfully prints the expected contents
of this array.
[…]
(rdb:1) c # now the above line of program code should execute without
error…and we get instead…

…/lib/setnet/SN.rb:550:in proc_command': undefined local variable or methodmenu_ut’ for #SN::SetNet:0xb79adac8 (NameError)

…and it blows.

How can this be?

I do know that if I make this variable a constant, in the input file,
all is well. But I had thought an ordinary variable would be fine, as
the input code is evaluated in the current binding…only it doesn’t
seem to be there (the variable), unless you ask ruby-debug, which says
it is.

I cannot make sense of this. And…I need to fix it somehow.

All suggestions most welcome.

Tom