open(FILE, "herbalarea.pl") || die "I can't open that because: $!\n"; while() { chop; @all = split(/\n/); foreach $line (@all) { local($hStoreID, $hStoreLatitude, $hStoreLongitude) = split(/ /, $line); $lat2 = $hStoreLatitude; $lon2 = $hStoreLongitude; $lat1 = $lat1a; $lon1 = $lon1a; # Notice the 90 - latitude: phi zero is at the North Pole. @L = (deg2rad($lat1), deg2rad(90 - $lon1)); @T = (deg2rad($lat2), deg2rad(90 - $lon2)); $km = great_circle_distance(@L, @T, 6378); #-------HERE IS THE PROBLEM---------# @km=sort {$a <=> $b} (@zip_dist); $km = (@zip_dist); #-----------------------------------# if ($km < $distance) { $match = 1; $count ++; $area = "$hStoreName
$hStoreAdd
$hStoreCity, $hStoreProv $hStorePC\n"; $rounded = sprintf("%.1f", $km); print " $area $km \n"; }