... # code to get things set up and vars defined etc. my $dbh=DBI->connect($datasource_with_RaiseError_1_and_AutoCommit_0); eval { $dbh->rollback; #this sets the time on the transaction to now my $sth=$dbh->prepare('INSERT INTO table ( name, email ) VALUES ( ?, ? )'); while(my($name,$email)=each %emaillist) { $sth->execute($name, $email); } $dbh->commit; ]; if($@) { $dbh->rollback; print STDERR "Something went wrong in insert: $@"; }