in reply to Whats quicker - passing along as variable to sub, or global var?

You are basically “benchmarking” the speed of the virtual memory subsystem.   And, you are using memory like a filesystem.

Don’t “diddle” code to make it faster -- find a better algorithm.
– The Elements of Programming Style