Hi people

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 :-

# 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.


In reply to strict, debug and global variables by meetn2veg

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.