$count = 0; my %inarea; open(FILE, "herbalarea.pl") || die "I can't open that because: $!\n"; while(my $line= ) { chomp $line; local($hStoreID, $hStoreName, $hStoreUserName, $hStorePassword, $hStoreMCRSPassword, $hStoreCity, $hStoreProv, $hStoreAdd, $hStoreAdd2, $hStorePC, $hStoreCountry, $hStoreEmail, $hStorePhone, $hStoreType, $hStoreLatitude, $hStoreLongitude, $hStoreFirstName, $hStoreLastName, $hStoreHPhone, $hStoreCPhone, $hStoreEmail2, $hStoreOwner, $hStoreAdmin, $hStoreAdmin2, $hStoreAdmin3, $hStoreActive, $hStoreWeb, $hStoreLang, $hStoreDesc, $hStoreShowMap, $hStoreComingSoonText, $hStoreComingSoonTextFrench, $hStoreVanityName, $hStoreWebCreatedDate, $hStoreLastLogin, $hStoreLastEnabled, $hStoreManagerEmpID, $hStoreURL) = split(/ /, $line); $lat2 = $hStoreLatitude; $lon2 = $hStoreLongitude; $lat1 = $lat1a; $lon1 = $lon1a; @L = (deg2rad($lat1), deg2rad(90 - $lon1)); @T = (deg2rad($lat2), deg2rad(90 - $lon2)); $km = great_circle_distance(@L, @T, 6378); if ($km < $distance) { $match = 1; $count ++; $area = "$hStoreName
$hStoreAdd
$hStoreCity, $hStoreProv $hStorePC\n"; $area1 = "$hStoreAdd $hStoreAdd2 $hStoreCity, $hStoreProv $hStorePC\n"; $area2 = "$hStoreCity, $hStoreProv\n"; $inarea{$km}= {area=>$area, area1=>$area1, hStore=>$hStore ... }; } foreach my $km ( sort keys %inarea ) { my $area= $inarea{$km}{area}; my $area1= $inarea{$km}{area1}; ... print "
Store # $area
\n"; print "
\n"; } } }