At 02:41 PM 6/20/02 +0200, Martin A. Hansen wrote:
>i will elaborate the question:
>
>
>i have a huge script with many global variables and subroutines.
>
>several variable names are reused, but lexically scoped to subroutines 
>and everything works fine.
>
>but if you forget (bugs do occur!) to declare a variable inside a 
>subroutine it will get the global variable value and there _may not_ 
>be any error upon compilation! however, the program will crash or 
>malfunction later on.
>
>what is the smart way to deal with this?

If you've got something that big...

(1) Reduce the number of globals.  If you have "many", there's 
something wrong that could be improved with better design.  If your 
script isn't object-oriented, it probably should be.

(2) Use a naming convention for globals, like $ALL_CAPS, or 
@Initial_cap that you don't use for any other variables.

--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com/


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to