in reply to DBI Can't call method "close" during global destruction

You should store a database handler into your object property:
sub DB_connect { my $self = shift; $self->{dbh} = DBI->connect( DBI_STRING ) || die "Cannot connect: $DBI::errstr\n"; } sub DB_finish { my $self = shift; $self->{dbh}->disconnect; }

For understanding Perl OO, please see Tutorials::Object Oriented Perl.
If you need to have a superstructure over DBI, it's enough to make it as module not necessary to create a class.
--------> SV* sv_bless(SV* sv, HV* stash);

Replies are listed 'Best First'.
Re: Re: DBI Can't call method "close" during global destruction
by Marcello (Hermit) on Mar 24, 2003 at 14:15 UTC
    I also suggest:
    sub DB_finish { my $self = shift; if (defined($self->{dbh})) { $self->{dbh}->disconnect; } }
    because if the database connect fails or is not called the dbh variable will be undefined and the same error will occur again.

    Regards,
    Marcel