http://www.perlmonks.org?node_id=521817


in reply to Not getting the expected result when using eval/alarm

try doing your dbi connect stuff like this:
eval { $db = DBI->connect("dbi:mysql:database="$remotedb"; host=127.0.0.1;p +ort=$port", "$user", "$pass", { RaiseError=>1, PrintError=>0 } ); }; if ($@){ #handle db error (ie, host not available.. blah blah }else{ return $db; }

Notice I added {RaiseError=>1, PrintError=>0} to your dbi call and then eval the call to DBI.

JamesNC