sub oft-used_func { .... if ($do_db_call) { my $sth = $dbh->prepare_cached($sql) || die; $sth->execute(@bind_vars) || die; while ($sth->fetch) { .... } # Use implicit close here # $sth->finish; } .... }