package MyDbConnection; use DBI; #... our $dbh; sub get_dbh { unless $dbh { #real connection here } return $dbh; }