Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: Suggestions requested: module to standardize postal address components?

by DrHyde (Prior)
on Jun 30, 2010 at 10:22 UTC ( #847290=note: print w/replies, xml ) Need Help??

in reply to Suggestions requested: module to standardize postal address components?

I can't think of any module that does what you want. If you decide to modularise your code and release it, do please remember that address formats vary widely from one place to another, and assuming that all addresses are of the form address/city/state/zip is incorrect: for example, in the UK there is no state field, what you have as a single line for "address" we would call "street address" (the whole thing is the address) and it may be split over several lines), and your "city" field may also be split over two (or more) lines. In general, the only structure you can assume is address/country, where address is free-form text over several lines. You can, of course, have country-specific code for picking that free-form text apart once you know what the country is.

Obviously you're only interested in US addresses, which is fine, but to make your code more useful to others (and hence make them more likely to give you bug fixes and cool new features) it would be a good idea to define a common interface which knows how to dispatch to country-specific modules, and to put the US-specific code in one of those that you bundle with the generic front-end.

  • Comment on Re: Suggestions requested: module to standardize postal address components?

Replies are listed 'Best First'.
Re^2: Suggestions requested: module to standardize postal address components?
by Jenda (Abbot) on Jul 01, 2010 at 09:40 UTC

    There also tends to be some kind of postal code, but the format of the code and the usual placement within the address differs.

    Enoch was right!
    Enjoy the last years of Rome.

      Apparently so-after a previous suggestion about research on international formats, I found a posting where someone was *cough*talking*cough* about that most everyone uses (if I remember this correctly) a general format of the most specific part (recipient) at top to the most general (country) at bottom, but with no particular standard of ordering in between-except for a few who want to do it in the other direction.

      Because of that, my thought was (should I get that far on this as releasable code) just to provide a way to deal with parts of an address component, and let the person using it be able to call what they need where they think they need it.

Re^2: Suggestions requested: module to standardize postal address components?
by atcroft (Abbot) on Jul 01, 2010 at 06:25 UTC

    Points well taken. My experience with postal addresses is limited to probably only a handful of instances of dealing with international addresses, the remainder being strictly US addresses. I realize my example was probably very simplistic/incorrect, but it was only to get an initial idea across. The USPS listing I based what I have played with so far upon had 3 types of address components [state or province, address unit, and secondary address unit], so what I had in mind was to only provide a few conversion functions (assuming that there might be other types of components pointed out later) that the user could then call as they saw fit on a portion of the entry as they needed.)

    I very much like the idea of the dispatch interface and country-specific modules to make it more flexible (but will also mean I will have to learn how to do such a thing as well :-).

      I did something similar in Number::Phone, which provides a generic interface and dispatches the hard work of parsing phone numbers to country-specific modules, so maybe you could get some ideas from that.

        Thanks! I grabbed a copy of that module code from CPAN to try to look at soon.

        I have really appreciated the insight and feedback. I hope I will have enough to-its to keep going on this for a while.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://847290]
and all is quiet...

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

    Results (126 votes). Check out past polls.