I've ben trying to convert a php script to work as perl and I must be missing somthing because all I am doing is trying to loop through a file and display listing that are under 30 miles away as in a store locator. It is easier to see what is going on then for me to explain, Any help is welcome.
#!/usr/local/bin/perl5 #------------------ was php--------------------------- funtion distance($lat1, $lon1, $lat2, $lon2, $unit) { $theta = $lon1 - $lon2; $dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($la +t1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta)); $dist = acos($dist); $dist = rad2deg($dist); $miles = $dist * 60 * 1.1515; $unit = strtoupper($unit); if ($unit == "K") { return ($miles * 1.609344); } elsif ($unit == "N") { return ($miles * 0.8684); } else { return $miles; } } #--------------------------end was php------------------------ { $selectmiles = 30; $zipcood = "60.1843160, -128.5069940"; open(FILE, "area.txt") || die "I can't open that because: $!\n"; while(<FILE>) { chop; @all = split(/\n/); foreach $line (@all) { local($hStoreID, $hStoreName, $hStoreUserName, $hStorePassword, $h +StoreMCRSPassword, $hStoreCity, $hStoreProv, $hStoreAdd, $hStoreAdd2, + $hStorePC, $hStoreCountry, $hStoreEmail, $hStorePhone, $hStoreType, +$hStoreLatitude, $hStoreLongitude, $hStoreFirstName, $hStoreLastName, + $hStoreHPhone, $hStoreCPhone, $hStoreEmail2, hStoreOwner, hStoreAdmi +n, $hStoreAdmin2, $hStoreAdmin3, $hStoreActive, $hStoreWeb, $hStoreLa +ng, $hStoreDesc, $hStoreShowMap, $hStoreComingSoonText, $hStoreComing +SoonTextFrench, $hStoreVanityName, $hStoreWebCreatedDate, $hStoreLast +Login, $hStoreLastEnabled, $hStoreManagerEmpID, $hStoreURL) = split(/ + /, $line); distance($zipcood, $hStoreLatitude, $hStoreLongitude "M") if ("M" < "selectmiles") { $match = 1; $centerinfo = "$hStoreID, $hStoreName\n"; } } } close(FILE, "area.txt")
Thanks in advance...

In reply to Zip code distance search by pglinx

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.