http://www.perlmonks.org?node_id=878536


in reply to Share data among different packages

I know it's not good a idea to use global variables and global data structures.
That's the disadvantage of sound-bites. They evolve into dogmas, and people take it for gospel.

It's a bad idea to use global variables and global data structures for local use. But if you want information to be accessible globally, there's nothing wrong with global variables. ("Singleton solution" make use of global variables as well - it's just a global coderef instead of global scalar/array/hash). The alternative is to set up your data locally, and pass references to it to every subroutine that either needs it, or calls (directly or indirectly) a subroutine that needs it.