my $dbh=bar(); foo($dbh); sub foo{ my $dbh=shift; # do something with the database handle.... } sub bar{ my $dbh=DBI->connect(...... return $dbh; }