in reply to Closures and scope

Yeah, well it is the key idea behind Why I like functional programming so I should give explaing it a shot. :-)

The idea of lexical scope is that the scope of the variable is defined by the text, it appears in, and its value is bound to that at run-time. So the scope of $x is inside of newprint (including the anon sub), and when you run newprint you get an anonymous function, which sees $x as being the value that it had on the invocation that you created it with.

So run newprint twice and you get two anonymous functions which are using different $x variables. That was just a demo. There really is no limit and in the link I gave you I create, oh, huge scads of copies of very similar functions that way. :-)