eval { my $dbh = DBI->connect("bad stuff here")...|| die "dead"; } if($@) { print "ERROR" }