my $dbh = DBI->connect(...); transaction $dbh, { for (1..10) { my $sth = $dbh->prepare(...); $sth->execute() or rollback; } }; #### transaction($dbh) { # code };