I number of years ago I was searching for just such a tool. What we ended up using was a product called the Postalsoft ACE library from Firstlogic. It is a C library and a database (about 650 MB). Data updates come every 2 months which you must apply or you cannot get CASS certified.
With this tool you can correct and encode any US address (they also have international and canadian libraries). Since this library is in C I was forced to build an xs extention. An example of the interface is...
use ACE; $ah = ACE->open("/u02/postalsoft/ace.cfg"); $ah->set_input_fields('discrete'); $ah->want_all_components(); $addr = '101 morris'; $city = 'sbastopul'; $state = 'CA'; $zip = ''; %a = $ah->find($addr, $city, $state, $zip); for my $key (qw(ADDRESS CITY ZIP ZIP4 COUNTY COUNTYNAME)) { print "$key = $a{$key}\n" if $a{$key}; } $ah->close();
This will produce output like ...
ADDRESS = 101 MORRIS ST
CITY = SEBASTOPOL
ZIP = 95472
ZIP4 = 3858
COUNTY = 097
COUNTYNAME = SONOMA
Note that the software fixed the street name, corrected the spelling of the city and added zip4, county and countyname fields.

I have never posted this code to CPAN because I've never looked into the legal issues. Postalsoft is not free. Our license fees are several thousand dollars a year. If you are interested in more details you can message me.

In reply to Re: Parsing an Mailing Addresss by mifflin
in thread Parsing an Mailing Addresss by Anonymous Monk

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.