meetn2veg has asked for the wisdom of the Perl Monks concerning the following question:
The saga continues! In recent weeks, I've been finding most of the bugs within my code thanks to help and advice from the more amicable monks out there. Once again I'd like to call upon their know-how.
There's no point in explaining the application - suffice to say it's huge! But, having been guided towards use strict; and debugging via FatalsToBrowser amongst other suggestions, I now would like to do the following; 'require'ing a config.lib file which contains about 20 variables which (in my opinion) should be global to the whole thing (for example, default language, directory locations, database files, etc...). Some threads here have discussed the pros/cons of using global/local/my/our declarations - the variables which I wish to declare will not be changed by anything; once they're set, they're set! So there's no fear of a bug developing somewhere withing the 100,000's of lines of code!
Is it still necessary to specify each variable within the (for example) index.cgi script using use vars qw($var1 $var2 etc...); or is there a way to declare them when the file is 'require'd ? Or am I missing the point seeing as though the snippet I'm using suggests :-
# Comment this BEGIN block out on production code for security
# Ensure all fatals go to browser during debugging and set-up # Comment this BEGIN block out on production code for security BEGIN { $|=1; # Flush the buffers (as they say!) print "Content-type: text/html\n\n"; use CGI::Carp('fatalsToBrowser'); }
This also has other implications for me - the index.cgi file is the main login aswell, so not only are there system-wide settings (which will not change), there are also several variables set when a user logs in, depending upon their permissions, their preferred language, etc... I was creating these dynamically, but can't do that now using strict!
Thanks to all those who have helped me out thus far (you know who you are!)
Regards as always - Richard.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: strict, debug and global variables
by Aristotle (Chancellor) on Sep 16, 2004 at 22:35 UTC | |
|
Re: strict, debug and global variables
by freddo411 (Chaplain) on Sep 16, 2004 at 23:48 UTC | |
|
Re: strict, debug and global variables
by davido (Cardinal) on Sep 17, 2004 at 00:03 UTC | |
by Aristotle (Chancellor) on Sep 17, 2004 at 00:09 UTC | |
by davido (Cardinal) on Sep 17, 2004 at 00:51 UTC | |
|
Re: strict, debug and global variables
by ihb (Deacon) on Sep 16, 2004 at 22:38 UTC | |
|
Re: strict, debug and global variables
by meetn2veg (Scribe) on Sep 17, 2004 at 05:45 UTC |