$database = "dbname"; require '/home/sites/jdb.cgi'; # now I can do whatever with $dbh
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.
Name "main::database" used only once: possible typo at ./sqltest.pl line 5.
And if I 'use strict', I get:
Global symbol "$database" requires explicit package name at ./sqltest.pl line 5.
Global symbol "$dbh" requires explicit package name at ./sqltest.pl line 8.
Execution of ./sqltest.pl aborted due to compilation errors.
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. :)
Jason
In reply to Good programming practice by Purdy
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |