[EMAIL PROTECTED] wrote: > > There's probably some other stuff I have missed, but it's a start. > > The general principal is that by declaring variables in as small > > a scope as > > possible, you reduce the probability of errors. > > ok, I'll work on everything you mentioned... thanks for the "generic" > perl lesson, I hope it will improve my programming in general (I know > it's quite lousy yet). > > One question left though, since $cgi is always the same throughout the > entire script (just behaving differently depending on the given > parameter), shouldn't it be global?
It is considered good practice to try to eliminate all global variables. Each subroutine should be passed all the information it needs. If you can pass $cgi as a parameter to your subroutines that use it, this is the proper way to do it. However... In practice, I find that it sometimes overly complicates matters to do things this way. If there is a variable like $cgi which is used by nearly all of my subroutines, then I will sometimes leave it as a global rather than tacking it onto every subroutine call in the program. If you do this, you should specify it in a comment when you first declare the variable. This will help you out in a year or two when you have to go back and modify the program. -- Bowie _______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
