Lexical variables declared (with my) outside of of any block or function will be visible until the end of the file. Lexical variables declared in a block or in a function will be accessible only until the end of the block or the function. You can create a pseudo main() function if you wish to reduce the scope of your variables.