You will often find that you want to terminate a page before the
end. This doesn't necessarily indicate an error condition; it can be
just that you've done all you want to do. When you do this, it is good
to first clean up, otherwise you can get annoying warnings showing up
in your error logs. I use the following framework. /cleanup.html is Executed from
/base.html , and it is the last thing that is done. It calls the
cleanup() function in the /subs.html file: /cleanup.html
[-
$subs->cleanup ();
-] /subs.html
[!
sub cleanup
{
while (($name, $query) = each (%domain::query))
{
$query->finish();
}
$domain::dbh->disconnect();
} sub clean_exit
{
cleanup();
exit();
}
!] Now, whenever I want to exit prematurely, I use a call to
$subs->clean_exit() rather than just exit(). This makes sure that the
queries and database connections are shut down nicely.
|