in reply to Re: Includes, strict and pointers.
in thread Includes, strict and pointers.

Hi,

To add my $0.02... if you're going the OO way, you can add a DESTROY {} routine which checks for open DB connections and properly closes them before going out of scope. This is especially useful when using commit/rollback (you should do a rollback in this case of course!).

sub DESTROY { $self = shift; # assume database handle is stored in blessed object if ($self->{dbh}) $self->{dbh}->rollback(); $self->{dbh}->disconnect() || croak $self->{dbh}->errstr; } }

I like this "trick" very much, because it saves me if some unforeseen error occurs and of course it serves the virtue of laziness.

--
Cheers, Joe