Geo::PostalAddress is a Perl module for country-specific postal address parsing/formatting.
This module converts postal (snail mail) addresses between an unstructured country-neutral format (an array of character strings) and a country-specific format that's hopefully meaningful by postal authorities, courier/delivery services, residents, ... of that country for postal address entry. It should handle most countries out of the box with only minor or technical divergences from approved bulk-mailing formats; if needed, country-specific code can be added to make it fully conformant to those formats.
The intended audience for this module is anyone needing to handle most addresses in a recognizable country-specific format, without going into the full generality and complexity that UPU standards would appear to require.
SYNOPSIS
use Geo::PostalAddress;
my $AU_parser = Geo::PostalAddress->new('AU');
my $format = $AU_parser->format();
# $format now contains:
# [['Addr1', 40], ['Addr2', 40], ['Addr3', 40], ['Addr4', 40], 3,
# ['City', 40],
# ['State', {NSW => "New South Wales", TAS => "Tasmania",
# QLD => "Queensland", SA => "South Australia",
# WA => "Western Australia", VIC => "Victoria",
# ACT => "Australian Capital Territory",
# NT => "Northern Territory"}], ['Postcode', 4, qr/^dddd$/]]
# 40 in ['Addr1', 40] is the suggested displayed field width (not the maximum
# length). 3 means that the next 3 fields should/could be on the same row.
# ['State', {...}] means an enumerated list is used for this field, with keys
# being the stored values and values being the labels used for display or
# selection.
my $display = $AU_parser->display(["4360 DUKES RD", "KALGOORLIE WA 6430"]);
# $display now contains:
# {Addr1 => "4360 DUKES RD", City => "KALGOORLIE",
# State => "WA", Postcode => "6430"}
my $US_parser = Geo::PostalAddress->new('US');
my $address = {Addr1 => "123 MAGNOLIA ST", City => "HEMPSTEAD",
State => "NY", ZIP => "115501234"};
my $result = $US_parser->storage($address);
unless (ref $result) { carp "Bad postal address: $result.n"; }
my $AU_to_US_address_label = $US_parser->label("AU", "MR JOHN DOE", $result);
# What to print on an address label or on an envelope, if mailing from
# Australia to the United States.
Product's homepage
Requirements:
· Perl