From: "Ranga Nathan" <[EMAIL PROTECTED]>
   Date: Thu, 22 Feb 2001 16:01:26 -0800

   I have a module that does some database (mySQL) i/o.
   I am wondering what is the best way to make sure that DISCONNECT occurs
   after all the processing. Do I have to provide a destructor that does it?
   What gets called when the module clean up occurs? I tried END {...} but it
   does not seem to kick in. I get this warning on my web page:

If it is an OO module, then DESTROY is where the cleanup belongs.
An example from a module I have lying about:

sub DESTROY {
  my($self) = shift;
  delete $self->{Templates};
  $self->{DBI}->disconnect if ref($self->{DBI});
  delete $self->{DBI};
}

If you are maintaining a DBI connection pool, or if all objects share
a DBI connection, or if you aren't using objects, then you'll need
something else.  Probably involving END.

--kag

Reply via email to