#!/usr/bin/perl # # stdaddr # # Copyright (C) 2003-2006 Gregor N. Purdy. All rights reserved. # This program is free software. It is subject to the same license as Perl. # # [ $Id: stdaddr 2208 2006-07-04 19:51:51Z gregor $] # use strict; use warnings; use lib 'lib'; use Scrape::USPS::ZipLookup::Address; use Scrape::USPS::ZipLookup; my $default_address = '401 E. 34th St.'; my $default_city = 'New York'; my $default_state = 'NY'; my $default_zip = '12401'; print "Street Address: "; my $address = ; chomp $address; die "Street address is required!\n" unless $address; print "City : "; my $city = ; chomp $city; print "State : "; my $state = ; chop $state; print "Zip : "; my $zip = ; chomp $zip; die "City and State are required if Zip is not given!\n" if not $zip and not ($city and $state); my $addr = Scrape::USPS::ZipLookup::Address->new( { 'Delivery Address' => $address, 'City' => $city, 'State' => $state, 'Zip Code' => $zip } ); my $zlu = Scrape::USPS::ZipLookup->new(); #$zlu->verbose(1); my @matches = $zlu->std_addr($addr); if (@matches) { printf "\n%d matches:\n", scalar(@matches); foreach my $match (@matches) { print "-" x 39, "\n"; # print $match->to_string; print $match->to_dump; print "\n"; } print "-" x 39, "\n"; } else { print "No matches!\n"; } exit 0;