in reply to Variable scope & subroutines

Your summary of my functionality is roughly correct - the docs discuss it in Private Variables via my(). The two code examples you have posted should be functionally equivalent.

When I hear about issues like this, the conclusion I draw is that you have created a closure through a typographical error. You should be able to track this down using -c and strict by changing the name of the top-level variable. If you post a less sanitized version, we should be able to help debug.