Hey Joel, that looks great! Thanks a lot (for solving the mystery of the sprintf problem, too :-) > Use a hash? > > vars = { > "a" => nil, > "b" => nil, > "c" => nil, > } > > def get_input vars > vars.keys.each do |var| > print "#{var} = " > val = gets > vars[var] = val.chomp > eval("$#{var}=#{val.chomp}") > end > end > > get_input vars > p vars > __END__ > a = 1 > b = 2 > c = 3 > {"a"=>"1", "b"=>"2", "c"=>"3"} > > > You can use instance_eval with the hash, as you suggested: > > module AcessibleKeys > def method_missing(m, *rest) > if rest.empty? > fetch(m.to_s) > else > super > end > end > end > > vars.extend AcessibleKeys > > get_input vars > p vars > > vars.instance_eval do > puts "a+b+c = #{a+b+c}" > end > __END__ > a = 1 > b = 2 > c = 3 > {"a"=>"1", "b"=>"2", "c"=>"3"} > a+b+c = 123 >