mattg has asked for the wisdom of the Perl Monks concerning the following question:
I am in need of some wisdom. I am working on what is becoming an ever more enormous script (about 4000 lines now and still growing, but mostly because it employs the Tk module to build a gui to a database), and beginning to worry about the way that I'm passing variables to the various subroutines.
Until writing this script, I had always passed variables to subroutines via @_ (and had blindly assumed that was the only way), but this script requires access to a number of pseudo-constants (values that are not constant, but the user is limited to only certain selections). Consequently, after a little investigation, I discovered that you could access globally scoped 'my' variables from within subroutines, so rather than needlessly keep passing the same pseudo-constants to each subroutine, I just started accessing them as I would within any other block of code.
Now that I'm nearing the end of this phase of the project, I'm starting to look at the code for any missed bugs or obvious failures, and this (what seems to me now possibly reckless) use of variables has me worried.
So I guess my question is, does anyone see any obvious failures in this approach? I realize that passing variables by reference will prevent accidental modifications of the original, but these values are never modified in the subroutines (i.e., they are used to specify which database to access, etc.). Anyone want to pat me on the head and reassure that I haven't committed a heinous coding crime?
Thanks in advance,
matt
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Passing variables is as easy as passing gas
by dragonchild (Archbishop) on Nov 02, 2001 at 23:14 UTC | |
|
(jeffa) Re: Passing variables is as easy as passing gas
by jeffa (Bishop) on Nov 03, 2001 at 00:00 UTC | |
by mattg (Novice) on Nov 03, 2001 at 01:20 UTC |