in reply to persistent DB connection

This is something Apache::DBI does. If you want to do it yourself, you could look at that source for ideas. Basically it holds the database handle for you. When you ask for it, it checks (with the $dbh->ping method) to see that it's still alive and reconnects it if necessary before giving it back to you.

Replies are listed 'Best First'.
Re^2: persistent DB connection
by perrin (Chancellor) on Dec 09, 2008 at 20:19 UTC
    The DBI->connect_cached method does all that too. Apache::DBI adds some web-specific stuff, like disabling disconnect() for porting of old CGI scripts, avoiding caching during server startup, and rolling back any unfinished transactions that could be left at the end of a request if your code died.