$dbh_ship = DBI->connect("DBI:mysql:db_name:localhost", "user", "passwd", \%attr ) || die "Could not connect to database: " . DBI->errstr; $sql_str_ship = "SELECT * FROM shipping WHERE street1='' ORDER BY ship_id"; $sth_ship = $dbh_ship->prepare($sql_str_ship); $sth_ship->execute(); while (@shipping = $sth_ship->fetchrow_array()) { # and so forth....