Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^4: Zip Code Module?

by sgifford (Prior)
on Dec 17, 2004 at 04:28 UTC ( #415551=note: print w/replies, xml ) Need Help??


in reply to Re^3: Zip Code Module?
in thread Zip Code Module?

As sifen said, you need to download the postal code database, as explained in the INSTALL file. This is an unfortunate aspect of this module. The author said he'd accept a fix if I emailed him one; perhaps in the next few weeks I can find some time to do that.

I think part of your problem, though, is that $postal_codes has an array reference, so you need to print it like this:

print "@$postal_codes";

Replies are listed 'Best First'.
Re^5: Zip Code Module?
by powerhouse (Friar) on Dec 17, 2004 at 06:59 UTC
    In the install file this is said: "Make sure to install the postalcode.db, city.db and latlon.db files in an approriate directory."

    I don't see where any of the .db files are. They are not in the .gz file that it shows. Where are those located? I went up one directory, and looked in all the files, they are not there, either.

    thx,
    Richard
      It also said:
      To install, run lwp-download http://tjmather.com/Geo-PostalCode_19991101.txt.gz gunzip Geo-PostalCode_19991101.txt.gz ./load.pl # this will take a few seconds...

      After that you'll have those files.

        Ok, I went through and ran every line of the code it said to do. on the first line, lwp-download... I got an error saying this:
        lwp-download: Aborted Will not save <http://tjmather.com/Geo-PostalCode_19991101.txt.gz> as +"Geo-PostalCode\x5f19991101.txt.gz". Please override file name on the command line.
        so I did it like this:  wget http://tjmather.com/Geo-PostalCode_19991101.txt.gz then did the rest like it said. I manually saved and uploaded all the installation files from here: http://search.cpan.org/src/TJMATHER/Geo-PostalCode-0.06/

        When I uploaded them the files in /t that end with .t somehow ended up with .t.txt file names so I had to rename those.

        After all was said and done, I did a test with this code:
        use Geo::PostalCode; my ($lat, $lon, $city, $state, $distance, $_record, $_db_dir, $gp, + $_zip); $_db_dir = "/etc/zip/edgetest"; $gp = Geo::PostalCode->new(db_dir => $_db_dir) or die "Could not c +reate a New Instance!"; $_zip = param("zip"); $_record = $gp->lookup_postal_code('postal_code' => "$_zip") or di +e "Could not Lookup Postal Code!"; $lat = $_record->{lat}; $lon = $_record->{lon}; $city = $_record->{city}; $state = $_record->{state}; $distance = $gp->calculate_distance(postal_codes => ["$_zip",'7485 +1']) or die "Could not get distance 3!"; $postal_codes = $gp->nearby_postal_codes(lat => $lat, lon => + $lon, distance => 50); $_page_content .= qq~<br> City is ~ . $city . qq~<br> State is ~ . $state . qq~<br> Latitude is ~ . $lat . qq~<br> Longitude is ~ . $lon . qq~<br> <br> Nearby Zips are: ~ . @$postal_codes . qq~<br> <br> The Distance from $_zip to US is $distance miles<br> <br>~; # $_page_content is printed at the end of # the index.cgi file for the # content...
        I added the 'die' parts for debugging because it was not working. I am getting this message: Could not Lookup Postal Code! So it is failing at this part of the code:    $_record = $gp->lookup_postal_code('postal_code' => "$_zip") or die "Could not Lookup Postal Code!";

        Can you see a reason why this would not be working and failing at that location?

        Thanks for any further assistance you can be. I will appreciate any and all advice on the matter.

        thx,
        Richard

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://415551]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2021-03-03 02:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favorite kind of desktop background is:











    Results (69 votes). Check out past polls.

    Notices?