eval { #table A foreach line (...) { prepare, execute, commit } #table B prepare, execute, commit } if ( $@ ) { rollback; }