in reply to Naming Convention For Global Variables?

What I do is to use constant to define constants, and, insofar as possible, I define one application-wide place in which I store global values of interest.   That place is an object, and there is a subroutine which is used to return its value.   This subroutine, and all others like it, creates and initializes the necessary “singleton” structure on-demand the first time it is called.

Since the global-values stash is an object, with methods, this gives me a fine degree of control and a good debugging-point.   When other parts of the system need access to a particular value, I want them to go through a short subroutine at a single known location to get it ... ditto for manipulating the value.   The actual variable that stores the value is in a private scope.

You see, any and every use of a “global anything” creates an undocumented coupling among all of its various clients, “wherever they might be,” and nothing traceable “happens” when they refer to it.   I don’t like that, largely because I deal with so much crufty code that did that.   Replacing a global value with a short sub that returns it is one of my many “tricks.”

It works for me because in my case I can easily afford the “extra” microseconds that it takes.   There are others here, e.g. BrowserUK, who will have an entirely different perspective because they ordinarily deal with very CPU-intensive problems that have to squeeze the CPU-clock for every nanosecond that it can spare.