Locale::US(3pm)
π Locale::US β the manual, but make it make sense π
okay bestie, so this is Locale::US, a Perl module (a 3pm page, if we're being specific) and it does exactly one iconic thing: it knows every US state's two-letter code and every state name, and it can flip between them in both directions. No cap. That's the whole vibe. state identification in the United States and vice versa β¨
β¨ SYNOPSIS β¨
here's the whole thing, copy it, it's giving copy-paste energy:
use Locale::US;
my $u = Locale::US->new;
my $state = $u->{code2state}{$code};
my $code = $u->{state2code}{$state};
my @state = $u->all_state_names;
my @code = $u->all_state_codes;
πΈ ABSTRACT πΈ
It's a map, babes. US two-letter codes β states, and states β two-letter codes. Both ways. Slay.
π DESCRIPTION π
πΊοΈ MAPPING
$self->{code2state}β a hashref where the key is the two-letter state name and the value is the long name. So you look up by code, you get the whole government name back. π$self->{state2code}β a hashref where the key is the long name and the value is the two-letter state name. Reverse it, flip it, turn it around. π
π DUMPING
$self->all_state_namesβ returns an array (NOT an arrayref, bestie, an actual@array) of all the state names, in alphabetical form. π$self->all_state_codesβ returns an array (again, NOT an arrayref) of all the state codes, in alphabetical form. π€
π KNOWN BUGS AND LIMITATIONS π
listen, we love her, but she has flaws:
- The state name comes back in
uc()format. That's the uppercase thing, iykyk. π - neither hash is strict, though they should be. fr fr, they should be. π
π₯ SEE ALSO π₯
π Locale::Country
Locale::Country β go check it out, it's the international cousin.
π Abbreviations
<http://www.usps.gov/ncsc/lookups/usps_abbreviations.htm>
Online file with the USPS two-letter codes for the United States and its possessions.
π οΈ AUXILIARY CODE:
lynx -dump http://www.usps.gov/ncsc/lookups/usps_abbreviations.htm > kruft.txt
kruft2codes.pl
π AUTHOR π
Currently maintained by Mike Accardo, <accardo@cpan.org>
Original author T. M. Brannon
π©Ή PATCHES
Thanks to stevet AT ibrinc for a patch about second call to new failing. π«Ά
π COPYRIGHT π
Copyright (c) 2015 Mike Accardo
Copyright (c) 2002-2014 Terrence Brannon
All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Periodt. β
kay that's the whole page, bestie!! πβ¨ this gorgeous thing was pulled from perl v5.36.0, dated 2022-11-19, and it lives at Locale::US(3pm) β go read a state code, you deserve it ππ¦πΈ
π¦ where this page comes from
- debian bookworm: liblocale-us-perl 3.04-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: liblocale-us-perl 3.04-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: liblocale-us-perl 3.04-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: liblocale-us-perl 3.04-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: liblocale-us-perl 3.04-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms