
May 15th, 2004, 12:57 AM
|
|
Contributing User
|
|
Join Date: Oct 2003
Posts: 421
Time spent in forums: 2 Days 12 h 50 m 2 sec
Reputation Power: 5
|
|
|
$dbh masks earlier declaration error
In one perl script I am running several SQL selects. What I have done is taken the code below and just changed the SQL selects. All the decalarations are the same for $dbh just $sql changes. The problem is that I get the follwing errors:
"my" variable $dbh masks earlier declaration
Global symbol "$dbh" requires explicit package name
I still want to use strict
How can I fix this. thanks
Code:
# connect to DB
my $dbh = DBI->connect ("DBI:mysql:$db:$localhost",
"$username","$password")
|| die "Could not connect to database: "
. DBI-> errstr; # display error
# If time is expired then push into array
my $sql = qq{ SELECT id FROM data WHERE item= '$ref->[0]' and time_expire > '$epoch_today' };
my $sth = $dbh->prepare( $sql );
$sth->execute();
|