use DBI; my $dbh; open_db_conn(); my @active_homes = get_active_homes(); $dbh->disconnect(); sub open_db_conn { my $dbd = "mysql"; my $host = "host_name"; my $db_name = "db_name"; my $user = "login"; my $password = "pass"; my $dsn = "DBI:$dbd:$db_name:$host"; eval { $dbh = DBI->connect( $dsn, $user, $password, { RaiseError => 1, AutoCommit => 0 } ); }; print "Could not open database connection: $@" if $@; } # &open_db_conn # Get active homes. # sub get_active_homes { my $sth = $dbh->prepare( qq{ call myProc() } ); $sth->execute(); print "Trouble with database connection: $@" if $@; } # &get_active_homes