Good programming practiceby Purdy (Hermit)
|on Nov 03, 2001 at 20:48 UTC||Need Help??|
Purdy has asked for the wisdom of the Perl Monks concerning the following question:
Seeking some advice here. I finally got my centralized script to work, but I cannot get it to work with 'use strict' and I get warnings with '-w'. Whenever I use my central script, the script that uses it, looks something like:
So when I slap in the '-w' (err, really I start with it - no honestly! :)), I get the following errors:
Name "main::dbh" used only once: possible typo at ./sqltest.pl line 8.
And if I 'use strict', I get:
Global symbol "$database" requires explicit package name at ./sqltest.pl line 5.
I put in a 'main::' in front of the variable names and that does fix it (not the warnings), but is that the solution? Putting 'main::' in front of everything?
I've heard of this 'our' declaration, but I don't have the latest version of Perl to have that (but if that's the answer, I'd still like to know).
If you check out the linked node, you'll see why I have/want this centralized script and the reason I designed it that way. But I don't like not being able to use the '-w' and 'use strict' ... am I doomed to have it only one way or another? Or is there a better way?
My next move is to read through the perldoc on the strict pragma. I guess I don't really understand that. But I'd still like to know if there's a better way to design such a system. Thanks in advance for the enlightenment! I look forward to learning an elegant solution. :)