I've hit a problem rather early on with use strict;!
I am writing some code mostly to test a module I am writing for this purpose -> To Extend, to Use, to Create - of course, the new code has use strict; at the begining thanks to the good influence of the Monks...
#!/usr/bin/perl
use strict;
require "incl/common.pl";
require "incl/html.pl";
my $update_time = $dbh->selectrow_array("SELECT NOW()");
The problem I am getting is Global symbol "$dbh" requires explicit package name at eric.pl line 7. The variable $dbh is a database handle from DBD::mysql and it is defined in require "incl/common.pl"; without the my keyword.
I have tried adding my $dbh; before the require statement thinking that I could simply declare the variable before assigning it within common.pl but that still gives Can't call method "selectrow_array" on an undefined value. As should be clear from the filename, common.pl is used by every script on the website so changing the way the database handle is declared and defined is not something I would want to do lightly...although I doubt anything untoward would happen I would rather know.
Any thoughts on how I should proceed? |