Who are you?
merlyn said "Both 'passing around' and 'global variables' are a signs of a misdesign....provide a higher-level interface that don't need to expose that variable...create a module..."
That sounds like a script using local variables might require a different structure. Obviously, scoping a variable to a certain block means it shouldn't be needed outside that block (or "region"), and that takes more planning, and some luck.
Another obvious bit of effort comes from declaring variables, and even by using "my".