#!/usr/bin/perl
#
# stdaddr
#
# Copyright (C) 2003-2012 Gregor N. Purdy, Sr. All rights reserved.
# This program is free software. It is subject to the same license as Perl.
#
# [ $Id$]
#
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 = <STDIN>;
chomp $address;
die "Street address is required!\n" unless $address;
print "City : ";
my $city = <STDIN>;
chomp $city;
print "State : ";
my $state = <STDIN>;
chop $state;
print "Zip : ";
my $zip = <STDIN>;
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;