From: Paul Brannan Date: 2003-06-25T04:55:31+09:00 Subject: Re: Inspecting a caller environment? On Tue, Jun 24, 2003 at 11:31:09PM +0900, Luigi Ballabio wrote: > Foo> foo = 'life' > Foo> bar = 'the universe' > Foo> baz = 'everything' > Foo> calculate > ==> 42 > Foo> This should produce exactly the result you are looking for: require 'readline' def create_binding return binding end $b = create_binding def calculate foo = eval 'foo', $b bar = eval 'bar', $b baz = eval 'baz', $b if foo == 'life' and bar == 'the universe' and baz == 'everything' puts " ==> 42" end end while line = Readline.readline('Foo> ') do eval line, $b end You may need to modify the code slightly if you do not have Readline available on your platform. See also [ruby-talk:22963]. Paul