my $dbh = get_db_handle(); my $company_name = get_company_name(company_id => $comp_id, dbh => $dbh, ); $dbh->disconnect; sub get_db_handle { # Do whatever you need to get the DB handle and set # your favorite options my $dbh = DBI->connect(...); error('DB connect') unless defined $dbh; } sub get_company_name { my %args = @_; my $dbh = $args{dbh}; my $statement = 'select comp_name from company where comp_name = ?'; my $sth = $dbh->prepare($sql) || error('prep_sql', $0); $sth->execute(@bind_params) || error('sql', $0); my ($company_name) = $sth->fetchrow_array; $sth->finish; return $company_name; }