eval { $sth = $dbh->prepare("select pass from users where user=?"); $sth->execute($user_name); }; if ($@) { # handle database error }