Your closure approach looks about the same as using a global, and I think using a global is a more obvious approach in this case. I doubt there's a significant difference between using a global and using $_[0] (an implicit pass-by-reference), so I would use the latter to make the code more readable.