line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# -*- Mode: Perl -*- |
2
|
|
|
|
|
|
|
################### Original code was by |
3
|
|
|
|
|
|
|
# ITIID : $ITI$ $Header $__Header$ |
4
|
|
|
|
|
|
|
# Author : Ulrich Pfeifer |
5
|
|
|
|
|
|
|
# Created On : Mon Aug 28 16:37:39 1995 |
6
|
|
|
|
|
|
|
# Last Modified By: Ulrich Pfeifer |
7
|
|
|
|
|
|
|
# Last Modified On: Sun Mar 24 14:21:39 1996 |
8
|
|
|
|
|
|
|
# Language : Perl |
9
|
|
|
|
|
|
|
# Update Count : 5 |
10
|
|
|
|
|
|
|
# Status : Unknown, Use with caution! |
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
# (C) Copyright 1995, Universität Dortmund, all rights reserved. |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
# HISTORY |
15
|
|
|
|
|
|
|
# |
16
|
|
|
|
|
|
|
# $Locker: pfeifer $ |
17
|
|
|
|
|
|
|
# $Log: Country.pm,v $ |
18
|
|
|
|
|
|
|
# Revision 0.1.1.1 1996/03/25 11:19:18 pfeifer |
19
|
|
|
|
|
|
|
# patch1: |
20
|
|
|
|
|
|
|
# |
21
|
|
|
|
|
|
|
# Revision 1.1 1996/03/24 13:33:52 pfeifer |
22
|
|
|
|
|
|
|
# Initial revision |
23
|
|
|
|
|
|
|
# |
24
|
|
|
|
|
|
|
# |
25
|
|
|
|
|
|
|
######### Changed database to FIPS, renamed to a new module |
26
|
|
|
|
|
|
|
# BUG: iso2fips will yield wrong answers with Yemen, Virgin Islands |
27
|
|
|
|
|
|
|
# or simillar countries with doubles |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
package Geography::Country::FIPS; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
require Exporter; |
32
|
|
|
|
|
|
|
@EXPORT_OK = qw(Name Code country2fips fips2country iso2fips fips2iso); |
33
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
$VERSION = 1.06; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub DATA (); |
38
|
|
|
|
|
|
|
foreach (split(/\n/, +DATA())) { |
39
|
|
|
|
|
|
|
($cc, $rest) = split(' ', $_, 2); |
40
|
|
|
|
|
|
|
next unless $cc; |
41
|
|
|
|
|
|
|
$country{$cc} = $rest; |
42
|
|
|
|
|
|
|
$rest =~ s/\s*\(.*\)\s*$//; |
43
|
|
|
|
|
|
|
$rest =~ s/,.*$//; |
44
|
|
|
|
|
|
|
$cross{lc($rest)} = $cc; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
2
|
|
|
2
|
0
|
1226
|
sub Name { goto &country2fips } |
48
|
1
|
|
|
1
|
0
|
13
|
sub Code { goto &fips2country } |
49
|
|
|
|
|
|
|
|
50
|
2
|
50
|
|
2
|
0
|
17
|
sub country2fips { $country{uc($_[0])} || $_[0] } |
51
|
1
|
50
|
|
1
|
0
|
11
|
sub fips2country { $cross{lc($_[0])} || $_[0] } |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub iso2fips { |
54
|
1
|
|
|
1
|
0
|
5
|
my $c = uc(shift); |
55
|
1
|
50
|
|
|
|
6
|
return "GM" if ($c eq 'DE'); |
56
|
1
|
50
|
|
|
|
34
|
return "KR" if ($c eq 'KS'); |
57
|
1
|
50
|
|
|
|
4
|
return "KP" if ($c eq 'KN'); |
58
|
1
|
|
|
|
|
345
|
require Net::Country; |
59
|
0
|
|
|
|
|
0
|
my $n = Net::Country::Name($c); |
60
|
0
|
0
|
|
|
|
0
|
return undef unless ($n); |
61
|
0
|
|
|
|
|
0
|
$n =~ s/\s*\(.*?\)\s*//; |
62
|
0
|
|
|
|
|
0
|
return $cross{lc($n)}; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub fips2iso { |
66
|
1
|
|
|
1
|
0
|
3
|
my $c = uc(shift); |
67
|
1
|
50
|
|
|
|
4
|
return "DE" if ($c eq 'GM'); |
68
|
1
|
50
|
|
|
|
5
|
return "KS" if ($c eq 'KR'); |
69
|
1
|
50
|
|
|
|
4
|
return "KN" if ($c eq 'KP'); |
70
|
1
|
|
|
|
|
4
|
my $n = Name($c); |
71
|
1
|
50
|
|
|
|
4
|
return undef unless ($n); |
72
|
1
|
|
|
|
|
3
|
$n =~ s/\s*\(.*?\)\s*//; |
73
|
1
|
|
|
|
|
7
|
require Geography::Country::TZ; |
74
|
1
|
|
|
|
|
6
|
return Geography::Country::TZ::from_iso($n); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
|
79
|
3
|
|
|
3
|
|
17
|
use constant DATA => << '.'; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
530
|
|
80
|
|
|
|
|
|
|
AA Aruba |
81
|
|
|
|
|
|
|
AC Antigua and Barbuda |
82
|
|
|
|
|
|
|
AF Afghanistan |
83
|
|
|
|
|
|
|
AG Algeria |
84
|
|
|
|
|
|
|
AL Albania |
85
|
|
|
|
|
|
|
AN Andorra |
86
|
|
|
|
|
|
|
AO Angola |
87
|
|
|
|
|
|
|
AQ American Samoa |
88
|
|
|
|
|
|
|
AR Argentina |
89
|
|
|
|
|
|
|
AS Australia |
90
|
|
|
|
|
|
|
AT Ashmore and Cartier Islands |
91
|
|
|
|
|
|
|
AU Austria |
92
|
|
|
|
|
|
|
AV Anguilla |
93
|
|
|
|
|
|
|
AY Antarctica |
94
|
|
|
|
|
|
|
BA Bahrain |
95
|
|
|
|
|
|
|
BB Barbados |
96
|
|
|
|
|
|
|
BC Botswana |
97
|
|
|
|
|
|
|
BD Bermuda |
98
|
|
|
|
|
|
|
BE Belgium |
99
|
|
|
|
|
|
|
BF Bahamas, The |
100
|
|
|
|
|
|
|
BG Bangladesh |
101
|
|
|
|
|
|
|
BH Belize |
102
|
|
|
|
|
|
|
BL Bolivia |
103
|
|
|
|
|
|
|
BM Burma |
104
|
|
|
|
|
|
|
BN Benin |
105
|
|
|
|
|
|
|
BP Solomon Islands |
106
|
|
|
|
|
|
|
BQ Navassa Island |
107
|
|
|
|
|
|
|
BR Brazil |
108
|
|
|
|
|
|
|
BS Bassas da India |
109
|
|
|
|
|
|
|
BT Bhutan |
110
|
|
|
|
|
|
|
BU Bulgaria |
111
|
|
|
|
|
|
|
BV Bouvet Island |
112
|
|
|
|
|
|
|
BX Brunei |
113
|
|
|
|
|
|
|
BY Burundi |
114
|
|
|
|
|
|
|
BZ Germany, Berlin |
115
|
|
|
|
|
|
|
CA Canada |
116
|
|
|
|
|
|
|
CB Cambodia |
117
|
|
|
|
|
|
|
CD Chad |
118
|
|
|
|
|
|
|
CE Sri Lanka |
119
|
|
|
|
|
|
|
CF Congo |
120
|
|
|
|
|
|
|
CG Zaire |
121
|
|
|
|
|
|
|
CH China |
122
|
|
|
|
|
|
|
CI Chile |
123
|
|
|
|
|
|
|
CJ Cayman Islands |
124
|
|
|
|
|
|
|
CK Cocos Islands |
125
|
|
|
|
|
|
|
CM Cameroon |
126
|
|
|
|
|
|
|
CN Comoros |
127
|
|
|
|
|
|
|
CO Colombia |
128
|
|
|
|
|
|
|
CQ Northern Mariana Islands |
129
|
|
|
|
|
|
|
CR Coral Sea Islands |
130
|
|
|
|
|
|
|
CS Costa Rica |
131
|
|
|
|
|
|
|
CT Central African Republic |
132
|
|
|
|
|
|
|
CU Cuba |
133
|
|
|
|
|
|
|
CV Cape Verde |
134
|
|
|
|
|
|
|
CW Cook Island |
135
|
|
|
|
|
|
|
CY Cyprus |
136
|
|
|
|
|
|
|
CZ Czechoslovakia |
137
|
|
|
|
|
|
|
DA Denmark |
138
|
|
|
|
|
|
|
DJ Djibouti |
139
|
|
|
|
|
|
|
DO Dominica |
140
|
|
|
|
|
|
|
DQ Jarvis Island |
141
|
|
|
|
|
|
|
DR Dominican Republic |
142
|
|
|
|
|
|
|
EC Ecuador |
143
|
|
|
|
|
|
|
EG Egypt |
144
|
|
|
|
|
|
|
EI Ireland |
145
|
|
|
|
|
|
|
EK Equatorial Guinea |
146
|
|
|
|
|
|
|
EN Estonia |
147
|
|
|
|
|
|
|
ES El Salvador |
148
|
|
|
|
|
|
|
ET Ethiopia |
149
|
|
|
|
|
|
|
EU Europa Island |
150
|
|
|
|
|
|
|
FG French Guiana |
151
|
|
|
|
|
|
|
FI Finland |
152
|
|
|
|
|
|
|
FJ Fiji |
153
|
|
|
|
|
|
|
FK Falkland Islands |
154
|
|
|
|
|
|
|
FM Micronesia |
155
|
|
|
|
|
|
|
FO Faroe Islands |
156
|
|
|
|
|
|
|
FP French Polynesia |
157
|
|
|
|
|
|
|
FQ Baker Island |
158
|
|
|
|
|
|
|
FR France |
159
|
|
|
|
|
|
|
FS French Southern and Antarctic Lands |
160
|
|
|
|
|
|
|
GA Gambia, The |
161
|
|
|
|
|
|
|
GB Gabon |
162
|
|
|
|
|
|
|
GC German Democratic Republic |
163
|
|
|
|
|
|
|
GE Germany, Federal Republic of |
164
|
|
|
|
|
|
|
GH Ghana |
165
|
|
|
|
|
|
|
GI Gibraltar |
166
|
|
|
|
|
|
|
GJ Grenada |
167
|
|
|
|
|
|
|
GK Guernsey |
168
|
|
|
|
|
|
|
GL Greenland |
169
|
|
|
|
|
|
|
GM Germany (1991) |
170
|
|
|
|
|
|
|
GN Gilbert and Ellice Islands |
171
|
|
|
|
|
|
|
GO Glorioso Islands |
172
|
|
|
|
|
|
|
GP Guadeloupe |
173
|
|
|
|
|
|
|
GQ Guam |
174
|
|
|
|
|
|
|
GR Greece |
175
|
|
|
|
|
|
|
GT Guatemala |
176
|
|
|
|
|
|
|
GV Guinea |
177
|
|
|
|
|
|
|
GY Guyana |
178
|
|
|
|
|
|
|
GZ Gaza Strip |
179
|
|
|
|
|
|
|
HA Haiti |
180
|
|
|
|
|
|
|
HK Hong Kong |
181
|
|
|
|
|
|
|
HM Heard and McDonald Islands |
182
|
|
|
|
|
|
|
HO Honduras |
183
|
|
|
|
|
|
|
HQ Howland Island |
184
|
|
|
|
|
|
|
HU Hungary |
185
|
|
|
|
|
|
|
IC Iceland |
186
|
|
|
|
|
|
|
ID Indonesia |
187
|
|
|
|
|
|
|
IM Man, Isle of |
188
|
|
|
|
|
|
|
IN India |
189
|
|
|
|
|
|
|
IO British Indian Ocean Territory |
190
|
|
|
|
|
|
|
IP Clipperton Island |
191
|
|
|
|
|
|
|
IR Iran |
192
|
|
|
|
|
|
|
IS Israel |
193
|
|
|
|
|
|
|
IT Italy |
194
|
|
|
|
|
|
|
IV Ivory Coast |
195
|
|
|
|
|
|
|
IY Iraq-Saudia Arabia Neutral Zone |
196
|
|
|
|
|
|
|
IZ Iraq |
197
|
|
|
|
|
|
|
JA Japan |
198
|
|
|
|
|
|
|
JE Jersey |
199
|
|
|
|
|
|
|
JM Jamaica |
200
|
|
|
|
|
|
|
JN Jan Mayen |
201
|
|
|
|
|
|
|
JO Jordan |
202
|
|
|
|
|
|
|
JQ Johnston Atoll |
203
|
|
|
|
|
|
|
JU Juan de Nova Island |
204
|
|
|
|
|
|
|
KE Kenya |
205
|
|
|
|
|
|
|
KN Korea (North) |
206
|
|
|
|
|
|
|
KQ Kingman Reef |
207
|
|
|
|
|
|
|
KR Kiribati |
208
|
|
|
|
|
|
|
KS Korea (South) |
209
|
|
|
|
|
|
|
KT Christmas Island |
210
|
|
|
|
|
|
|
KU Kuwait |
211
|
|
|
|
|
|
|
LA Laos |
212
|
|
|
|
|
|
|
LE Lebanon |
213
|
|
|
|
|
|
|
LG Latvia |
214
|
|
|
|
|
|
|
LH Lithuania |
215
|
|
|
|
|
|
|
LI Liberia |
216
|
|
|
|
|
|
|
LQ Palmyra Atoll |
217
|
|
|
|
|
|
|
LS Liechtenstein |
218
|
|
|
|
|
|
|
LT Lesotho |
219
|
|
|
|
|
|
|
LU Luxembourg |
220
|
|
|
|
|
|
|
LY Libya |
221
|
|
|
|
|
|
|
MA Madagascar |
222
|
|
|
|
|
|
|
MB Martinique |
223
|
|
|
|
|
|
|
MC Macau |
224
|
|
|
|
|
|
|
MF Mayotte |
225
|
|
|
|
|
|
|
MG Mongolia |
226
|
|
|
|
|
|
|
MH Montserrat |
227
|
|
|
|
|
|
|
MI Malawi |
228
|
|
|
|
|
|
|
ML Mali |
229
|
|
|
|
|
|
|
MN Monaco |
230
|
|
|
|
|
|
|
MO Morocco |
231
|
|
|
|
|
|
|
MP Mauritius |
232
|
|
|
|
|
|
|
MQ Midway Islands |
233
|
|
|
|
|
|
|
MR Mauritania |
234
|
|
|
|
|
|
|
MT Malta |
235
|
|
|
|
|
|
|
MU Oman |
236
|
|
|
|
|
|
|
MV Maldives |
237
|
|
|
|
|
|
|
MX Mexico |
238
|
|
|
|
|
|
|
MY Malaysia |
239
|
|
|
|
|
|
|
MZ Mozambique |
240
|
|
|
|
|
|
|
NC New Caledonia |
241
|
|
|
|
|
|
|
NE Niue |
242
|
|
|
|
|
|
|
NF Norfolk Island |
243
|
|
|
|
|
|
|
NG Niger |
244
|
|
|
|
|
|
|
NH Vanuatu |
245
|
|
|
|
|
|
|
NI Nigeria |
246
|
|
|
|
|
|
|
NL Netherlands |
247
|
|
|
|
|
|
|
NO Norway |
248
|
|
|
|
|
|
|
NP Nepal |
249
|
|
|
|
|
|
|
NR Nauru |
250
|
|
|
|
|
|
|
NS Suriname |
251
|
|
|
|
|
|
|
NT Netherlands Antilles |
252
|
|
|
|
|
|
|
NU Nicaragua |
253
|
|
|
|
|
|
|
NZ New Zealand |
254
|
|
|
|
|
|
|
PA Paraguay |
255
|
|
|
|
|
|
|
PC Pitcairn Islands |
256
|
|
|
|
|
|
|
PE Peru |
257
|
|
|
|
|
|
|
PF Paracel Islands |
258
|
|
|
|
|
|
|
PG Spratly Islands |
259
|
|
|
|
|
|
|
PK Pakistan |
260
|
|
|
|
|
|
|
PL Poland |
261
|
|
|
|
|
|
|
PM Panama |
262
|
|
|
|
|
|
|
PO Portugal |
263
|
|
|
|
|
|
|
PP Papua New Guinea |
264
|
|
|
|
|
|
|
PS Trust Territory of the Pacific |
265
|
|
|
|
|
|
|
PU Guinea-Bissau |
266
|
|
|
|
|
|
|
QA Qatar |
267
|
|
|
|
|
|
|
RE Reunion |
268
|
|
|
|
|
|
|
RM Marshall Islands |
269
|
|
|
|
|
|
|
RO Romania |
270
|
|
|
|
|
|
|
RP Philippines |
271
|
|
|
|
|
|
|
RQ Puerto Rico |
272
|
|
|
|
|
|
|
RW Rwanda |
273
|
|
|
|
|
|
|
SA Saudi Arabia |
274
|
|
|
|
|
|
|
SB St. Pierre and Miquelon |
275
|
|
|
|
|
|
|
SC St. Kitts and Nevis |
276
|
|
|
|
|
|
|
SE Seychelles |
277
|
|
|
|
|
|
|
SF South Africa |
278
|
|
|
|
|
|
|
SG Senegal |
279
|
|
|
|
|
|
|
SH St. Helena |
280
|
|
|
|
|
|
|
SL Sierra Leone |
281
|
|
|
|
|
|
|
SM San Marino |
282
|
|
|
|
|
|
|
SN Singapore |
283
|
|
|
|
|
|
|
SO Somalia |
284
|
|
|
|
|
|
|
SP Spain |
285
|
|
|
|
|
|
|
ST St. Lucia |
286
|
|
|
|
|
|
|
SU Sudan |
287
|
|
|
|
|
|
|
SV Svalbard |
288
|
|
|
|
|
|
|
SW Sweden |
289
|
|
|
|
|
|
|
SY Syria |
290
|
|
|
|
|
|
|
SZ Switzerland |
291
|
|
|
|
|
|
|
TC United Arab Emirates |
292
|
|
|
|
|
|
|
TD Trinidad & Tobago |
293
|
|
|
|
|
|
|
TE Tromelin Island |
294
|
|
|
|
|
|
|
TH Thailand |
295
|
|
|
|
|
|
|
TK Turks and Caicos Islands |
296
|
|
|
|
|
|
|
TL Tokelau |
297
|
|
|
|
|
|
|
TN Tonga |
298
|
|
|
|
|
|
|
TO Togo |
299
|
|
|
|
|
|
|
TP Sao Tome and Principe |
300
|
|
|
|
|
|
|
TS Tunisia |
301
|
|
|
|
|
|
|
TU Turkey |
302
|
|
|
|
|
|
|
TV Tuvalu |
303
|
|
|
|
|
|
|
TW Taiwan |
304
|
|
|
|
|
|
|
TZ Tanzania, United Republic of |
305
|
|
|
|
|
|
|
UA Ukraine |
306
|
|
|
|
|
|
|
UG Uganda |
307
|
|
|
|
|
|
|
UK United Kingdom |
308
|
|
|
|
|
|
|
UR USSR |
309
|
|
|
|
|
|
|
US United States |
310
|
|
|
|
|
|
|
UY Uruguay |
311
|
|
|
|
|
|
|
UV Burkina |
312
|
|
|
|
|
|
|
VC St. Vincent and the Grenadines |
313
|
|
|
|
|
|
|
VE Venezuela |
314
|
|
|
|
|
|
|
VI British Virgin Islands |
315
|
|
|
|
|
|
|
VM Vietnam |
316
|
|
|
|
|
|
|
VQ Virgin Islands |
317
|
|
|
|
|
|
|
VT Vatican City |
318
|
|
|
|
|
|
|
WA Namibia |
319
|
|
|
|
|
|
|
WE West Bank |
320
|
|
|
|
|
|
|
WF Wallis and Futuna |
321
|
|
|
|
|
|
|
WI Western Sahara |
322
|
|
|
|
|
|
|
WQ Wake Island |
323
|
|
|
|
|
|
|
WS Western Samoa |
324
|
|
|
|
|
|
|
WZ Swaziland |
325
|
|
|
|
|
|
|
YE Yemen (Sanaa) |
326
|
|
|
|
|
|
|
YO Yugoslavia |
327
|
|
|
|
|
|
|
YS Yemen (Aden) |
328
|
|
|
|
|
|
|
ZA Zambia |
329
|
|
|
|
|
|
|
ZI Zimbabwe |
330
|
|
|
|
|
|
|
. |