Eric Christopherson wrote in post #984033: > On Fri, Feb 25, 2011 at 2:53 PM, 7stud -- <bbxx789_05ss / yahoo.com> > wrote: >>> worry >>> about that too, and found out later it was not necessary. > [...] >> Uh oh. Someone is going to have to explain that to me. $1 does not act >> like a regular global variable: > > This is getting more confusing for me. I think your source of confusion is how closures work. I believe the following brief example demonstrates what you are seeing in my larger script: def do_stuff x = 'hello' p = Proc.new {puts x} x = 'goodbye' return p end my_callable = do_stuff my_callable.call --output:-- goodbye The block {puts x} closes over the *variable* x--not the value 'hello'. At the end of the def, x is still in scope and it is changed to 'goodbye'. Then when the def ends, x goes out of scope, so x can no longer be changed. That means that inside the block {puts x}, the value of x is 'goodbye'. -- Posted via http://www.ruby-forum.com/.