my $t = Transaction->new($dbh); $t->transaction(sub { for (1..10) { my $sth = $dbh->prepare(...); $sth->execute() or $t->rollback; } });