package Transactions; our $Object; sub import { my $class = shift; $Object = shift; # somehow fall back to Exporter::Tidy? # goto &Exporter::Tidy::import; maybe? } ... sub transaction(&) { ... eval { $$Object->begin_work(); # double $ because it's a ref-to-a-ref $block->(); } ... } =head1 SYNOPSIS my $dbh = DBI->connect(...); use Transactions \$dbh; transaction { for (1..10) { my $sth = $dbh->prepare(...); $sth->execute() or rollback; } }; ...