File Coverage

blib/lib/BW/AddressCodes.pm
Criterion Covered Total %
statement 15 17 88.2
branch n/a
condition n/a
subroutine 5 7 71.4
pod 2 2 100.0
total 22 26 84.6


line stmt bran cond sub pod time code
1             # AddressCodes.pm
2             # by Bill Weinman -- Address codes for Countries and US States
3             # Copyright (c) 1995-2010 The BearHeart Group, LLC
4             #
5             # See POD for History
6             #
7             package BW::AddressCodes;
8 1     1   1503 use strict;
  1         2  
  1         36  
9 1     1   6 use warnings;
  1         2  
  1         27  
10              
11 1     1   5 use BW::Constants;
  1         2  
  1         1016  
12 1     1   10 use base qw( BW::Base );
  1         125  
  1         210  
13              
14 1     1   6 use Exporter; # can't use qw( import ) with old version of perl
  1         2  
  1         2550  
15             our @EXPORT = qw ( us_state_codes country_codes );
16              
17             our $VERSION = "1.0";
18              
19             my $codes = {
20             us_state_codes => [
21             { text => "-- Select State --", value => "" },
22             { text => "Alabama", value => "AL" },
23             { text => "Alaska", value => "AK" },
24             { text => "American Samoa", value => "AS" },
25             { text => "Arizona", value => "AZ" },
26             { text => "Arkansas", value => "AR" },
27             { text => "California", value => "CA" },
28             { text => "Colorado", value => "CO" },
29             { text => "Connecticut", value => "CT" },
30             { text => "Delaware", value => "DE" },
31             { text => "District of Columbia", value => "DC" },
32             { text => "Florida", value => "FL" },
33             { text => "Georgia", value => "GA" },
34             { text => "Guam", value => "GU" },
35             { text => "Hawaii", value => "HI" },
36             { text => "Idaho", value => "ID" },
37             { text => "Illinois", value => "IL" },
38             { text => "Indiana", value => "IN" },
39             { text => "Iowa", value => "IA" },
40             { text => "Kansas", value => "KS" },
41             { text => "Kentucky", value => "KY" },
42             { text => "Louisiana", value => "LA" },
43             { text => "Maine", value => "ME" },
44             { text => "Marshall Islands", value => "MH" },
45             { text => "Maryland", value => "MD" },
46             { text => "Massachusetts", value => "MA" },
47             { text => "Michigan", value => "MI" },
48             { text => "Minnesota", value => "MN" },
49             { text => "Mississippi", value => "MS" },
50             { text => "Missouri", value => "MO" },
51             { text => "Montana", value => "MT" },
52             { text => "Nebraska", value => "NE" },
53             { text => "Nevada", value => "NV" },
54             { text => "New Hampshire", value => "NH" },
55             { text => "New Jersey", value => "NJ" },
56             { text => "New Mexico", value => "NM" },
57             { text => "New York", value => "NY" },
58             { text => "North Carolina", value => "NC" },
59             { text => "North Dakota", value => "ND" },
60             { text => "Northern Mariana Islands", value => "MP" },
61             { text => "Ohio", value => "OH" },
62             { text => "Oklahoma", value => "OK" },
63             { text => "Oregon", value => "OR" },
64             { text => "Palau", value => "PW" },
65             { text => "Pennsylvania", value => "PA" },
66             { text => "Puerto Rico", value => "PR" },
67             { text => "Rhode Island", value => "RI" },
68             { text => "South Carolina", value => "SC" },
69             { text => "South Dakota", value => "SD" },
70             { text => "Tennessee", value => "TN" },
71             { text => "Texas", value => "TX" },
72             { text => "Utah", value => "UT" },
73             { text => "Vermont", value => "VT" },
74             { text => "Virgin Islands", value => "VI" },
75             { text => "Virginia", value => "VA" },
76             { text => "Washington", value => "WA" },
77             { text => "West Virginia", value => "WV" },
78             { text => "Wisconsin", value => "WI" },
79             { text => "Wyoming", value => "WY" }
80             ],
81              
82             country_codes => [
83             { text => "United States", value => "US", selected => TRUE },
84             { text => "Canada", value => "CA" },
85             { text => "----------", value => "" },
86             { text => "Afghanistan", value => "AF" },
87             { text => "Albania", value => "AL" },
88             { text => "Algeria", value => "DZ" },
89             { text => "American Samoa", value => "AS" },
90             { text => "Andorra", value => "AD" },
91             { text => "Angola", value => "AO" },
92             { text => "Anguilla", value => "AI" },
93             { text => "Antarctica", value => "AQ" },
94             { text => "Antigua and Barbuda", value => "AG" },
95             { text => "Argentina", value => "AR" },
96             { text => "Armenia", value => "AM" },
97             { text => "Aruba", value => "AW" },
98             { text => "Australia", value => "AU" },
99             { text => "Austria", value => "AT" },
100             { text => "Azerbaijan", value => "AZ" },
101             { text => "Bahamas", value => "BS" },
102             { text => "Bahrain", value => "BH" },
103             { text => "Bangladesh", value => "BD" },
104             { text => "Barbados", value => "BB" },
105             { text => "Belarus", value => "BY" },
106             { text => "Belgium", value => "BE" },
107             { text => "Belize", value => "BZ" },
108             { text => "Benin", value => "BJ" },
109             { text => "Bermuda", value => "BM" },
110             { text => "Bhutan", value => "BT" },
111             { text => "Bolivia", value => "BO" },
112             { text => "Bosnia and Herzegovina", value => "BA" },
113             { text => "Botswana", value => "BW" },
114             { text => "Bouvet Island", value => "BV" },
115             { text => "Brazil", value => "BR" },
116             { text => "British Indian Ocean Territory", value => "IO" },
117             { text => "Brunei Darussalam", value => "BN" },
118             { text => "Bulgaria", value => "BG" },
119             { text => "Burkina Faso", value => "BF" },
120             { text => "Burundi", value => "BI" },
121             { text => "Cambodia", value => "KH" },
122             { text => "Cameroon", value => "CM" },
123             { text => "Canada", value => "CA" },
124             { text => "Cape Verde", value => "CV" },
125             { text => "Cayman Islands", value => "KY" },
126             { text => "Central African Republic", value => "CF" },
127             { text => "Chad", value => "TD" },
128             { text => "Chile", value => "CL" },
129             { text => "China", value => "CN" },
130             { text => "Christmas Island", value => "CX" },
131             { text => "Cocos (Keeling) Islands", value => "CC" },
132             { text => "Colombia", value => "CO" },
133             { text => "Comoros", value => "KM" },
134             { text => "Congo, the Democratic Republic of the", value => "CD" },
135             { text => "Congo", value => "CG" },
136             { text => "Cook Islands", value => "CK" },
137             { text => "Costa Rica", value => "CR" },
138             { text => "Cote d'Ivoire", value => "CI" },
139             { text => "Croatia", value => "HR" },
140             { text => "Cuba", value => "CU" },
141             { text => "Cyprus", value => "CY" },
142             { text => "Czech Republic", value => "CZ" },
143             { text => "Denmark", value => "DK" },
144             { text => "Djibouti", value => "DJ" },
145             { text => "Dominica", value => "DM" },
146             { text => "Dominican Republic", value => "DO" },
147             { text => "Ecuador", value => "EC" },
148             { text => "Egypt", value => "EG" },
149             { text => "El Salvador", value => "SV" },
150             { text => "Equatorial Guinea", value => "GQ" },
151             { text => "Eritrea", value => "ER" },
152             { text => "Estonia", value => "EE" },
153             { text => "Ethiopia", value => "ET" },
154             { text => "Falkland Islands (Malvinas)", value => "FK" },
155             { text => "Faroe Islands", value => "FO" },
156             { text => "Fiji", value => "FJ" },
157             { text => "Finland", value => "FI" },
158             { text => "France", value => "FR" },
159             { text => "French Guiana", value => "GF" },
160             { text => "French Polynesia", value => "PF" },
161             { text => "French Southern Territories", value => "TF" },
162             { text => "Gabon", value => "GA" },
163             { text => "Gambia", value => "GM" },
164             { text => "Georgia", value => "GE" },
165             { text => "Germany", value => "DE" },
166             { text => "Ghana", value => "GH" },
167             { text => "Gibraltar", value => "GI" },
168             { text => "Greece", value => "GR" },
169             { text => "Greenland", value => "GL" },
170             { text => "Grenada", value => "GD" },
171             { text => "Guadeloupe", value => "GP" },
172             { text => "Guam", value => "GU" },
173             { text => "Guatemala", value => "GT" },
174             { text => "Guernsey", value => "GG" },
175             { text => "Guinea-Bissau", value => "GW" },
176             { text => "Guinea", value => "GN" },
177             { text => "Guyana", value => "GY" },
178             { text => "Haiti", value => "HT" },
179             { text => "Heard Island and McDonald Islands", value => "HM" },
180             { text => "Holy See (Vatican City State)", value => "VA" },
181             { text => "Honduras", value => "HN" },
182             { text => "Hong Kong", value => "HK" },
183             { text => "Hungary", value => "HU" },
184             { text => "Iceland", value => "IS" },
185             { text => "India", value => "IN" },
186             { text => "Indonesia", value => "ID" },
187             { text => "Iran, Islamic Republic of", value => "IR" },
188             { text => "Iraq", value => "IQ" },
189             { text => "Ireland", value => "IE" },
190             { text => "Isle of Man", value => "IM" },
191             { text => "Israel", value => "IL" },
192             { text => "Italy", value => "IT" },
193             { text => "Jamaica", value => "JM" },
194             { text => "Japan", value => "JP" },
195             { text => "Jersey", value => "JE" },
196             { text => "Jordan", value => "JO" },
197             { text => "Kazakhstan", value => "KZ" },
198             { text => "Kenya", value => "KE" },
199             { text => "Kiribati", value => "KI" },
200             { text => "Korea, Democratic People's Republic of", value => "KP" },
201             { text => "Korea, Republic of", value => "KR" },
202             { text => "Kuwait", value => "KW" },
203             { text => "Kyrgyzstan", value => "KG" },
204             { text => "Lao People's Democratic Republic", value => "LA" },
205             { text => "Latvia", value => "LV" },
206             { text => "Lebanon", value => "LB" },
207             { text => "Lesotho", value => "LS" },
208             { text => "Liberia", value => "LR" },
209             { text => "Libyan Arab Jamahiriya", value => "LY" },
210             { text => "Liechtenstein", value => "LI" },
211             { text => "Lithuania", value => "LT" },
212             { text => "Luxembourg", value => "LU" },
213             { text => "Macao", value => "MO" },
214             { text => "Macedonia, the former Yugoslav Republic of", value => "MK" },
215             { text => "Madagascar", value => "MG" },
216             { text => "Malawi", value => "MW" },
217             { text => "Malaysia", value => "MY" },
218             { text => "Maldives", value => "MV" },
219             { text => "Mali", value => "ML" },
220             { text => "Malta", value => "MT" },
221             { text => "Marshall Islands", value => "MH" },
222             { text => "Martinique", value => "MQ" },
223             { text => "Mauritania", value => "MR" },
224             { text => "Mauritius", value => "MU" },
225             { text => "Mayotte", value => "YT" },
226             { text => "Mexico", value => "MX" },
227             { text => "Micronesia, Federated States of", value => "FM" },
228             { text => "Moldova, Republic of", value => "MD" },
229             { text => "Monaco", value => "MC" },
230             { text => "Mongolia", value => "MN" },
231             { text => "Montenegro", value => "ME" },
232             { text => "Montserrat", value => "MS" },
233             { text => "Morocco", value => "MA" },
234             { text => "Mozambique", value => "MZ" },
235             { text => "Myanmar", value => "MM" },
236             { text => "Namibia", value => "NA" },
237             { text => "Nauru", value => "NR" },
238             { text => "Nepal", value => "NP" },
239             { text => "Netherlands Antilles", value => "AN" },
240             { text => "Netherlands", value => "NL" },
241             { text => "New Caledonia", value => "NC" },
242             { text => "New Zealand", value => "NZ" },
243             { text => "Nicaragua", value => "NI" },
244             { text => "Niger", value => "NE" },
245             { text => "Nigeria", value => "NG" },
246             { text => "Niue", value => "NU" },
247             { text => "Norfolk Island", value => "NF" },
248             { text => "Northern Mariana Islands", value => "MP" },
249             { text => "Norway", value => "NO" },
250             { text => "Oman", value => "OM" },
251             { text => "Pakistan", value => "PK" },
252             { text => "Palau", value => "PW" },
253             { text => "Palestinian Territory, Occupied", value => "PS" },
254             { text => "Panama", value => "PA" },
255             { text => "Papua New Guinea", value => "PG" },
256             { text => "Paraguay", value => "PY" },
257             { text => "Peru", value => "PE" },
258             { text => "Philippines", value => "PH" },
259             { text => "Pitcairn", value => "PN" },
260             { text => "Poland", value => "PL" },
261             { text => "Portugal", value => "PT" },
262             { text => "Puerto Rico", value => "PR" },
263             { text => "Qatar", value => "QA" },
264             { text => "Reunion", value => "RE" },
265             { text => "Romania", value => "RO" },
266             { text => "Russian Federation", value => "RU" },
267             { text => "Rwanda", value => "RW" },
268             { text => "Saint Barthelemy", value => "BL" },
269             { text => "Saint Helena", value => "SH" },
270             { text => "Saint Kitts and Nevis", value => "KN" },
271             { text => "Saint Lucia", value => "LC" },
272             { text => "Saint Martin (French part)", value => "MF" },
273             { text => "Saint Pierre and Miquelon", value => "PM" },
274             { text => "Saint Vincent and the Grenadines", value => "VC" },
275             { text => "Samoa", value => "WS" },
276             { text => "San Marino", value => "SM" },
277             { text => "Sao Tome and Principe", value => "ST" },
278             { text => "Saudi Arabia", value => "SA" },
279             { text => "Senegal", value => "SN" },
280             { text => "Serbia", value => "RS" },
281             { text => "Seychelles", value => "SC" },
282             { text => "Sierra Leone", value => "SL" },
283             { text => "Singapore", value => "SG" },
284             { text => "Slovakia", value => "SK" },
285             { text => "Slovenia", value => "SI" },
286             { text => "Solomon Islands", value => "SB" },
287             { text => "Somalia", value => "SO" },
288             { text => "South Africa", value => "ZA" },
289             { text => "South Georgia and the South Sandwich Islands", value => "GS" },
290             { text => "Spain", value => "ES" },
291             { text => "Sri Lanka", value => "LK" },
292             { text => "Sudan", value => "SD" },
293             { text => "Suriname", value => "SR" },
294             { text => "Svalbard and Jan Mayen", value => "SJ" },
295             { text => "Swaziland", value => "SZ" },
296             { text => "Sweden", value => "SE" },
297             { text => "Switzerland", value => "CH" },
298             { text => "Syrian Arab Republic", value => "SY" },
299             { text => "Taiwan, Province of China", value => "TW" },
300             { text => "Tajikistan", value => "TJ" },
301             { text => "Tanzania, United Republic of", value => "TZ" },
302             { text => "Thailand", value => "TH" },
303             { text => "Timor-Leste", value => "TL" },
304             { text => "Togo", value => "TG" },
305             { text => "Tokelau", value => "TK" },
306             { text => "Tonga", value => "TO" },
307             { text => "Trinidad and Tobago", value => "TT" },
308             { text => "Tunisia", value => "TN" },
309             { text => "Turkey", value => "TR" },
310             { text => "Turkmenistan", value => "TM" },
311             { text => "Turks and Caicos Islands", value => "TC" },
312             { text => "Tuvalu", value => "TV" },
313             { text => "Uganda", value => "UG" },
314             { text => "Ukraine", value => "UA" },
315             { text => "United Arab Emirates", value => "AE" },
316             { text => "United Kingdom", value => "GB" },
317             { text => "United States Minor Outlying Islands", value => "UM" },
318             { text => "United States", value => "US" },
319             { text => "Uruguay", value => "UY" },
320             { text => "Uzbekistan", value => "UZ" },
321             { text => "Vanuatu", value => "VU" },
322             { text => "Venezuela", value => "VE" },
323             { text => "Viet Nam", value => "VN" },
324             { text => "Virgin Islands, British", value => "VG" },
325             { text => "Virgin Islands, U.S.", value => "VI" },
326             { text => "Wallis and Futuna", value => "WF" },
327             { text => "Western Sahara", value => "EH" },
328             { text => "Yemen", value => "YE" },
329             { text => "Zambia", value => "ZM" },
330             { text => "Zimbabwe", value => "ZW" },
331             ],
332              
333             stub => VOID
334             };
335              
336             sub us_state_codes
337             {
338 0     0 1   return $codes->{us_state_codes};
339             }
340              
341             sub country_codes
342             {
343 0     0 1   return $codes->{country_codes};
344             }
345              
346             1;
347              
348             =head1 NAME
349              
350             BW::AddressCodes - New module description
351              
352             =head1 SYNOPSIS
353              
354             use BW::AddressCodes;
355             my $o = BW::AddressCodes->new;
356              
357             =head1 METHODS
358              
359             =over 4
360              
361             =item B( )
362              
363             Constructs a new BW::AddressCodes object.
364              
365             Returns a blessed BW::AddressCodes object reference.
366             Returns undef (VOID) if the object cannot be created.
367              
368             =item B( )
369              
370             Returns the US state codes as an array of hashrefs.
371              
372             =item B( )
373              
374             Returns the country codes as an array of hashrefs.
375              
376             =item B
377              
378             Returns and clears the object error message.
379              
380             =back
381              
382             =head1 AUTHOR
383              
384             Written by Bill Weinman Ehttp://bw.org/E.
385              
386             =head1 COPYRIGHT
387              
388             Copyright (c) 1995-2010 The BearHeart Group, LLC
389              
390             =head1 HISTORY
391              
392             2010-02-14 bw 1.0 -- updated for CPAN distribution
393             2008-05-28 bw -- updated documentation
394             2008-04-14 bw -- initial version.
395              
396             =cut
397