Hi,
I'm trying to use the DBI within a package I'm
writing, and am getting an odd error (warning). What
is even more odd is that everything actually works
fine.
Here is what I am doing in the package:
package Package;
# class data
my $Dbh;
sub BEGIN {
$Dbh = DBI->connect("DBI:mysql:database=mydb",
{PrintError => 1, RaiseError
=> 0})
or croak "Cannot connect to mysql database:
$DBI::errstr\n";
}
....
sub END {
$Dbh->disconnect()
or croak "could not disconnect from database:
$DBI::errstr";
}
In between I run a routine which just dumps a list of
tables in the database, so my script looks something
like:
use Package;
Package->dumptables();
And I get a printout of the tables, which means it
must be connecting ok. I don't get the croak message
on the $Dbh->disconnect(), so that must also be
working. But I am getting:
Useless use of private variable in void context at
Package.pm line 56.
line 56 being the one that just contains:
$Dbh->disconnect()
so it must be saying $Dbh is being used in a void
context. But if that were the case, surely the
disconnect method call would fail with cannot call
method on undefined object?
Any help appreciated.
Tom
____________________________________________________________
Do You Yahoo!?
Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk
or your free @yahoo.ie address at http://mail.yahoo.ie