sub make_all_reports { # connect to the database my $dbh = &_get_dbh; &make_summary_report($dbh); &make_report1($dbh); &make_report1($dbh); ... # close the database connection $dbh->disconnect; # return happy and healthy return (1); } #### sub make_report1 { # connect to the database my $dbh = shift; $dbh = &_get_dbh if (!defined($dbh)); ... my $caller = caller(1); # close the database connection if opened here $dbh->disconnect if (!defined $caller); # return happy and healthy return (1); }