From: Philip Mak Date: 2002-07-10T09:10:45+09:00 Subject: Accessing caller's binding? I'm trying to make a function that is called like this: cgi.export(%w(name email phone)) which would have the same effect as this: name = cgi['name'][0] email = cgi['email'][0] phone = cgi['phone'][0] Since there doesn't seem to be a way to get the binding of the caller automatically, I had to try stuff like: cgi.export(%w(name email phone), binding()) # cgi.export uses the binding to eval and eval cgi.export(%w(name email phone)) # cgi.export returns code to set the variables But I can't get it to work. Apparently, it doesn't seem to be possible to create a variable in this fashion. Observe the following piece of code, which looks like it should work but doesn't: $ ruby -e"eval 'x = 3'; puts x" -e:1: undefined local variable or method `x' for # (NameError) Does anyone have ideas on how I could create such a function, or am I trying to do the impossible? I want to minimize the amount of code that has to be typed by the caller.