Locale::SubCountry - convert state, county, province etc names to/from code
use Locale::SubCountry; $UK_counties = new Locale::SubCountry('UK'); print($UK_counties->full_name('DUMGAL')); # Dumfries & Galloway $country = 'AUSTRALIA'; @all_countries = &all_countries; if ( grep(/$country/, @all_countries) ) { $australia = new Locale::SubCountry($country); } else { die "No data for $country"; } print($australia->code('New South Wales ')); # NSW print($australia->full_name('S.A.')); # South Australia $upper_case = 1; print($australia->full_name('Qld',$upper_case)); # QUEENSLAND %all_australian_states = $australia->full_name_code_hash; foreach $abbrev ( sort keys %australian_states ) { printf("%-3s : %s\n",$abbrev,%all_australian_states{$abbrev}); } %all_australian_codes = $australia->code_full_name_hash; @all_australian_states = $australia->all_full_names; @all_australian_codes = $australia->all_codes;
Perl 5.005 or above
perl Makefile.PL make make test make install
This module allows you to convert the full name for a countries administrative region to the code commonly used for postal addressing. The reverse conversion can also be done.
Subcountry regions are defined as states in the US and Australia, provinces in Canada and counties in the UK.
Additionally, names and codes for all subcountry regions in a country can be returned as either a hash or an array.
Copyright (c) 2000 Kim Ryan. All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the Perl Artistic License (see http://www.perl.com/perl/misc/Artistic.html).
Locale::SubCountry was written by Kim Ryan <kimaryan@ozemail.com.au> in 2000.
Terrence Brannon produced Locale::US, which was the starting point for this module.
Abbreviations for Canadian, Netherlands and Brazilian regions were taken from Geography::States.
Mark Summerfield and Guy Fraser provided the list of UK counties.
To install Locale::SubCountry, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Locale::SubCountry
CPAN shell
perl -MCPAN -e shell install Locale::SubCountry
For more information on module installation, please visit the detailed CPAN module installation guide.