my $i = 4; eval { my $sql = qq(insert into test values (?)); my $sth = $dbh->prepare($sql); $sth->execute($i); }; if ($@) { print "$@\n"; }