my $tied = 0; while (!$tied) { eval { tie %session, 'Apache::Session::MySQL', $session, { Handle => HH::DB->db_Main, LockHandle => HH::DB->db_Main }; if ($@) { if ($@ =~ /^Object does not exist/) { $session = undef; } else { print $cgi->header; die_nice('Database Error', 'Unable to connect at this time'); } } else { $tied = 1; } }