NAME
Geo::Address::Formatter - take structured address data and format it according to the various global/country rules
VERSION
version 1.0.0
SYNOPSIS
my $GAF = Geo::Address::Formatter->new( conf_path => '/some/path' );
my $components = { ... }
my $text = $GAF->format_address($components, { country => 'fr'} );
DESCRIPTION
You have a structured postal address (hash) and need to convert it into a readable address based on the format of the address country.
For example
{
house_number => 12,
street => 'Some street',
postcode => 45678,
city => 'Nirvana'
}
Great Britain: Some street 12, Nirvana 45678
France: 12 Some street, 45678 Nirvana
Germany: Some street 12, 45678 Nirvana
It gets more complicated with 100 countries and dozens more address components to consider.
This module comes with a minimal configuration to run tests. Instead of developing your own configuration you should use (and contribute to) those in https://github.com/lokku/address-formatting. It includes test cases.
METHODS
new
my $GAF = Geo::Address::Formatter->new( conf_path => '/some/path' );
Returns one instance. The default conf_path is that of the test suite and isn't suitable for "real" addresses.
format_address
my $text = $GAF->format_address(\%components, \%options );
Given a structures address (hashref) and options (hashref) returns a formatted address.
The only option you can set currently is 'country_code' which should be an uppercase ISO_3166-1_alpha-2 code, e.g. 'UK' for Great Britain. If ommited we try to find the country in the address components.
AUTHOR
mtmail <mtmail-cpan@gmx.net>
COPYRIGHT AND LICENSE
This software is copyright (c) 2014 by Lokku Limited.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.