line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Locale::US::CensusDivisions; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
15095
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
4
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
17
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
3
|
use Exporter; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
27
|
|
7
|
1
|
|
|
1
|
|
3
|
use Carp qw(croak); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
207
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
10
|
|
|
|
|
|
|
our @EXPORT_OK = qw( state2division ); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# ABSTRACT: Locale::US::CensusDivisions - module to get US Census Divisions |
13
|
|
|
|
|
|
|
our $VERSION = '1.1.0'; # VERSION 1.1.0 |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=pod |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=encoding utf8 |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 NAME |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Locale::US::CensusDivisions - Module to provide Census Bureau Divisions |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 SYNOPSIS |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
use strict; |
26
|
|
|
|
|
|
|
use warnings; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
use Locale::US::CensusDivisions qw(state2division); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $division = state2division('TX'); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
print "The division for that state is $division \n"; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 DESCRIPTION |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
This module takes a US state abbreviation and returns the division number associated with that state. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 METHODS |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 state2division |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
See Synopsis |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
This module currently only supports US states and District of Columbia. |
47
|
|
|
|
|
|
|
It does not support US territories. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 AUTHOR |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Daniel Culver, C<< perlsufi@cpan.org >> |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Wikipedia L |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
L |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 CONTRIBUTORS |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
William Seymour |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Doug Schrag |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Robert Stone |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
our %divisions = ( |
74
|
|
|
|
|
|
|
1 => [ 'CT', 'ME', 'MA', 'NH', 'RI', 'VT' ], |
75
|
|
|
|
|
|
|
2 => [ 'NJ', 'NY', 'PA' ], |
76
|
|
|
|
|
|
|
3 => [ 'IL', 'IN', 'WI', 'MI', 'OH' ], |
77
|
|
|
|
|
|
|
4 => [ 'MN', 'KS', 'IA', 'MO', 'NE', 'ND', 'SD' ], |
78
|
|
|
|
|
|
|
5 => [ 'DE', 'FL', 'GA', 'MD', 'NC', 'SC', 'VA', 'DC', 'WV' ], |
79
|
|
|
|
|
|
|
6 => [ 'AL', 'KY', 'MS', 'TN' ], |
80
|
|
|
|
|
|
|
7 => [ 'AR', 'LA', 'OK', 'TX' ], |
81
|
|
|
|
|
|
|
8 => [ 'AZ', 'CO', 'ID', 'MT', 'NV', 'NM', 'UT', 'WY', ], |
82
|
|
|
|
|
|
|
9 => [ 'CA', 'WA', 'HI', 'OR', 'AK' ], |
83
|
|
|
|
|
|
|
); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub state2division { |
86
|
53
|
|
33
|
53
|
1
|
2418
|
my $code = shift |
87
|
|
|
|
|
|
|
|| croak 'state2division requires a state abbreviation string'; |
88
|
|
|
|
|
|
|
|
89
|
53
|
|
|
|
|
73
|
for my $division ( keys %divisions ) { |
90
|
273
|
100
|
|
|
|
144
|
if ( grep { $code eq $_ } @{ $divisions{$division} } ) { |
|
1563
|
|
|
|
|
1363
|
|
|
273
|
|
|
|
|
232
|
|
91
|
52
|
|
|
|
|
69
|
return $division; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
1
|
|
|
|
|
19
|
croak "The state abbreviation ($code) you provided was not found"; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
1; |