in reply to check if DBI is still connected

See options $dbi->{'RaiseError'} and $dbi->{'PrintError'}, querrying on a dead database will always throw an error or a warning respectively. If you set RaiseError to 1, and set PrintError to 0 (default), and capture the error message from $DBI::stderr after an eval, you can run a regex to see if it matches that of a failed connection, if it fails, reconnect and try again.

eval { $dbi = blah; $sth = blah }; if ($@ && $DBI::stderr =~ m/Bad Connection/) {reconnect and start again}


Evan Carroll
www.EvanCarroll.com