Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Foreign Postal Addresses

by aardvark (Pilgrim)
on Oct 10, 2001 at 03:05 UTC ( #117891=perlquestion: print w/replies, xml ) Need Help??
aardvark has asked for the wisdom of the Perl Monks concerning the following question:

A project I am woking on requires me to display lots of postal addresses for many countries. All of the addresses are entered into a common template. But displaying this info in the correct format for a given country is a problem. Each country has it's own format and I want to be geographically correct in the way it is displayed. Many countries use a similar format

address 1
address 2
address 3
city, (state or province) postal code

But I am finding some countries that use a different order:

address 1
address 2
address 3
city postal code, country

address 1
address 2
address 3
postal code city, country

I'm sure that each country has it's own standard address format. Has anybody found a module that incorporates all this logic? So given a country name (or country code) the module outputs the correct format?

Also if any of you have the address for the Taliban in Afghanistan, please give it to me, I'd like to send them a big punch in the mouth.

Get Strong Together!!

Replies are listed 'Best First'.
Re: Foreign Postal Addresses
by aardvark (Pilgrim) on Oct 10, 2001 at 04:28 UTC
    chromatic was nice enough to point out the correct module in a /msg to me.

    The module I was looking for is Lingua::EN::AddressParse .

    I overlooked it in my search of the CPAN. Thanks for helping me out chromatic.

    Get Strong Together!!

      Not exactly a Perl thing, but I beg you (everyone, not just Chromatic), if you are collecting addresses online, to consider how different nationalities use words to describe different parts of an address. For example:
      • most non-Americans have no idea what a zip code is.
      • the word "city" hasa completely different meaning in the UK from in the US. (When I am asked for my "city" my response is "I don't live in a city".)
      Also don't put in validation that will exclude non-US addresses e.g.
      • zip code validation
      • state abbreviation validation
      • US phone number validation.
      Just because it can be done doesn't mean you have to do it!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://117891]
Approved by root
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2018-06-23 14:27 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (125 votes). Check out past polls.