in reply to global variables vs global hash

Generally, keeping state in global data is a design mistake. And simply changing the global state from global variables to a global hash doesn't fix it.

Instead you should re-think the design of your program. Some relevant general software design tips taken from On Coding Standards and Code Reviews that might help are: