my $sql = 'select foo from bar'; my $sth; unless ($sth = $dbh->prepare_cached($sql)) { #raise an error, finish with this statement }