line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Telephony::CountryDialingCodes; |
2
|
|
|
|
|
|
|
# $Id: CountryDialingCodes.pm,v 1.4 2009/11/02 19:46:32 cmanley Exp $ |
3
|
|
|
|
|
|
|
# See POD documentation below. |
4
|
1
|
|
|
1
|
|
847
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
5
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
909
|
|
6
|
|
|
|
|
|
|
our $VERSION = sprintf('%d.%02d', q|$Revision: 1.4 $| =~ m/ (\d+) \. (\d+) /xg); |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# Private global 'constants'. |
10
|
|
|
|
|
|
|
our %DIALING_ISO3166 = ( |
11
|
|
|
|
|
|
|
1 => [qw(AG AI AS BB BM BS CA DM DO GD GU JM LC KN KY MP MS PR TC TT US VC VG VI)], |
12
|
|
|
|
|
|
|
20 => 'EG', |
13
|
|
|
|
|
|
|
212 => [qw(MA EH)], |
14
|
|
|
|
|
|
|
213 => 'DZ', |
15
|
|
|
|
|
|
|
216 => 'TN', |
16
|
|
|
|
|
|
|
218 => 'LY', |
17
|
|
|
|
|
|
|
220 => 'GM', |
18
|
|
|
|
|
|
|
221 => 'SN', |
19
|
|
|
|
|
|
|
222 => 'MR', |
20
|
|
|
|
|
|
|
223 => 'ML', |
21
|
|
|
|
|
|
|
224 => 'GN', |
22
|
|
|
|
|
|
|
225 => 'CI', |
23
|
|
|
|
|
|
|
226 => 'BF', |
24
|
|
|
|
|
|
|
227 => 'NE', |
25
|
|
|
|
|
|
|
228 => 'TG', |
26
|
|
|
|
|
|
|
229 => 'BJ', |
27
|
|
|
|
|
|
|
230 => 'MU', |
28
|
|
|
|
|
|
|
231 => 'LR', |
29
|
|
|
|
|
|
|
232 => 'SL', |
30
|
|
|
|
|
|
|
233 => 'GH', |
31
|
|
|
|
|
|
|
234 => 'NG', |
32
|
|
|
|
|
|
|
235 => 'TD', |
33
|
|
|
|
|
|
|
236 => 'CF', |
34
|
|
|
|
|
|
|
237 => 'CM', |
35
|
|
|
|
|
|
|
238 => 'CV', |
36
|
|
|
|
|
|
|
239 => 'ST', |
37
|
|
|
|
|
|
|
240 => 'GQ', |
38
|
|
|
|
|
|
|
241 => 'GA', |
39
|
|
|
|
|
|
|
242 => 'CG', |
40
|
|
|
|
|
|
|
243 => 'CD', |
41
|
|
|
|
|
|
|
244 => 'AO', |
42
|
|
|
|
|
|
|
245 => 'GW', |
43
|
|
|
|
|
|
|
246 => 'IO', |
44
|
|
|
|
|
|
|
247 => 'AC', |
45
|
|
|
|
|
|
|
248 => 'SC', |
46
|
|
|
|
|
|
|
249 => 'SD', |
47
|
|
|
|
|
|
|
250 => 'RW', |
48
|
|
|
|
|
|
|
251 => 'ET', |
49
|
|
|
|
|
|
|
252 => 'SO', |
50
|
|
|
|
|
|
|
253 => 'DJ', |
51
|
|
|
|
|
|
|
254 => 'KE', |
52
|
|
|
|
|
|
|
255 => 'TZ', |
53
|
|
|
|
|
|
|
256 => 'UG', |
54
|
|
|
|
|
|
|
257 => 'BI', |
55
|
|
|
|
|
|
|
258 => 'MZ', |
56
|
|
|
|
|
|
|
260 => 'ZM', |
57
|
|
|
|
|
|
|
261 => 'MG', |
58
|
|
|
|
|
|
|
262 => 'RE', |
59
|
|
|
|
|
|
|
263 => 'ZW', |
60
|
|
|
|
|
|
|
264 => 'NA', |
61
|
|
|
|
|
|
|
265 => 'MW', |
62
|
|
|
|
|
|
|
266 => 'LS', |
63
|
|
|
|
|
|
|
267 => 'BW', |
64
|
|
|
|
|
|
|
268 => 'SZ', |
65
|
|
|
|
|
|
|
269 => [qw(KM YT)], |
66
|
|
|
|
|
|
|
27 => 'ZA', |
67
|
|
|
|
|
|
|
290 => 'SH', |
68
|
|
|
|
|
|
|
291 => 'ER', |
69
|
|
|
|
|
|
|
297 => 'AW', |
70
|
|
|
|
|
|
|
298 => 'FO', |
71
|
|
|
|
|
|
|
299 => 'GL', |
72
|
|
|
|
|
|
|
30 => 'GR', |
73
|
|
|
|
|
|
|
31 => 'NL', |
74
|
|
|
|
|
|
|
32 => 'BE', |
75
|
|
|
|
|
|
|
33 => 'FR', |
76
|
|
|
|
|
|
|
34 => 'ES', |
77
|
|
|
|
|
|
|
350 => 'GI', |
78
|
|
|
|
|
|
|
351 => 'PT', |
79
|
|
|
|
|
|
|
352 => 'LU', |
80
|
|
|
|
|
|
|
353 => 'IE', |
81
|
|
|
|
|
|
|
354 => 'IS', |
82
|
|
|
|
|
|
|
355 => 'AL', |
83
|
|
|
|
|
|
|
356 => 'MT', |
84
|
|
|
|
|
|
|
357 => 'CY', |
85
|
|
|
|
|
|
|
358 => 'FI', |
86
|
|
|
|
|
|
|
359 => 'BG', |
87
|
|
|
|
|
|
|
36 => 'HU', |
88
|
|
|
|
|
|
|
370 => 'LT', |
89
|
|
|
|
|
|
|
371 => 'LV', |
90
|
|
|
|
|
|
|
372 => 'EE', |
91
|
|
|
|
|
|
|
373 => 'MD', |
92
|
|
|
|
|
|
|
374 => 'AM', |
93
|
|
|
|
|
|
|
375 => 'BY', |
94
|
|
|
|
|
|
|
376 => 'AD', |
95
|
|
|
|
|
|
|
377 => 'MC', |
96
|
|
|
|
|
|
|
378 => 'SM', |
97
|
|
|
|
|
|
|
379 => 'VA', |
98
|
|
|
|
|
|
|
380 => 'UA', |
99
|
|
|
|
|
|
|
381 => 'RS', |
100
|
|
|
|
|
|
|
382 => 'ME', |
101
|
|
|
|
|
|
|
385 => 'HR', |
102
|
|
|
|
|
|
|
386 => 'SI', |
103
|
|
|
|
|
|
|
387 => 'BA', |
104
|
|
|
|
|
|
|
388 => 'EU', |
105
|
|
|
|
|
|
|
389 => 'MK', |
106
|
|
|
|
|
|
|
39 => 'IT', |
107
|
|
|
|
|
|
|
40 => 'RO', |
108
|
|
|
|
|
|
|
41 => 'CH', |
109
|
|
|
|
|
|
|
420 => 'CZ', |
110
|
|
|
|
|
|
|
421 => 'SK', |
111
|
|
|
|
|
|
|
423 => 'LI', |
112
|
|
|
|
|
|
|
43 => 'AT', |
113
|
|
|
|
|
|
|
44 => 'GB', |
114
|
|
|
|
|
|
|
45 => 'DK', |
115
|
|
|
|
|
|
|
46 => 'SE', |
116
|
|
|
|
|
|
|
47 => 'NO', |
117
|
|
|
|
|
|
|
48 => 'PL', |
118
|
|
|
|
|
|
|
49 => 'DE', |
119
|
|
|
|
|
|
|
500 => 'FK', |
120
|
|
|
|
|
|
|
501 => 'BZ', |
121
|
|
|
|
|
|
|
502 => 'GT', |
122
|
|
|
|
|
|
|
503 => 'SV', |
123
|
|
|
|
|
|
|
504 => 'HN', |
124
|
|
|
|
|
|
|
505 => 'NI', |
125
|
|
|
|
|
|
|
506 => 'CR', |
126
|
|
|
|
|
|
|
507 => 'PA', |
127
|
|
|
|
|
|
|
508 => 'PM', |
128
|
|
|
|
|
|
|
509 => 'HT', |
129
|
|
|
|
|
|
|
51 => 'PE', |
130
|
|
|
|
|
|
|
52 => 'MX', |
131
|
|
|
|
|
|
|
53 => 'CU', |
132
|
|
|
|
|
|
|
54 => 'AR', |
133
|
|
|
|
|
|
|
55 => 'BR', |
134
|
|
|
|
|
|
|
56 => 'CL', |
135
|
|
|
|
|
|
|
57 => 'CO', |
136
|
|
|
|
|
|
|
58 => 'VE', |
137
|
|
|
|
|
|
|
590 => 'GP', |
138
|
|
|
|
|
|
|
591 => 'BO', |
139
|
|
|
|
|
|
|
592 => 'GY', |
140
|
|
|
|
|
|
|
593 => 'EC', |
141
|
|
|
|
|
|
|
594 => 'GF', |
142
|
|
|
|
|
|
|
595 => 'PY', |
143
|
|
|
|
|
|
|
596 => 'MQ', |
144
|
|
|
|
|
|
|
597 => 'SR', |
145
|
|
|
|
|
|
|
598 => 'UY', |
146
|
|
|
|
|
|
|
599 => 'AN', |
147
|
|
|
|
|
|
|
60 => 'MY', |
148
|
|
|
|
|
|
|
61 => [qw(AU CC CX)], |
149
|
|
|
|
|
|
|
62 => 'ID', |
150
|
|
|
|
|
|
|
63 => 'PH', |
151
|
|
|
|
|
|
|
64 => 'NZ', |
152
|
|
|
|
|
|
|
65 => 'SG', |
153
|
|
|
|
|
|
|
66 => 'TH', |
154
|
|
|
|
|
|
|
670 => 'TL', |
155
|
|
|
|
|
|
|
672 => [qw(AQ NF)], |
156
|
|
|
|
|
|
|
673 => 'BN', |
157
|
|
|
|
|
|
|
674 => 'NR', |
158
|
|
|
|
|
|
|
675 => 'PG', |
159
|
|
|
|
|
|
|
676 => 'TO', |
160
|
|
|
|
|
|
|
677 => 'SB', |
161
|
|
|
|
|
|
|
678 => 'VU', |
162
|
|
|
|
|
|
|
679 => 'FJ', |
163
|
|
|
|
|
|
|
680 => 'PW', |
164
|
|
|
|
|
|
|
681 => 'WF', |
165
|
|
|
|
|
|
|
682 => 'CK', |
166
|
|
|
|
|
|
|
683 => 'NU', |
167
|
|
|
|
|
|
|
685 => 'WS', |
168
|
|
|
|
|
|
|
686 => 'KI', |
169
|
|
|
|
|
|
|
687 => 'NC', |
170
|
|
|
|
|
|
|
688 => 'TV', |
171
|
|
|
|
|
|
|
689 => 'PF', |
172
|
|
|
|
|
|
|
690 => 'TK', |
173
|
|
|
|
|
|
|
691 => 'FM', |
174
|
|
|
|
|
|
|
692 => 'MH', |
175
|
|
|
|
|
|
|
7 => [qw(RU KZ)], |
176
|
|
|
|
|
|
|
800 => 'XT', |
177
|
|
|
|
|
|
|
808 => 'XS', |
178
|
|
|
|
|
|
|
81 => 'JP', |
179
|
|
|
|
|
|
|
82 => 'KR', |
180
|
|
|
|
|
|
|
84 => 'VN', |
181
|
|
|
|
|
|
|
850 => 'KP', |
182
|
|
|
|
|
|
|
852 => 'HK', |
183
|
|
|
|
|
|
|
853 => 'MO', |
184
|
|
|
|
|
|
|
855 => 'KH', |
185
|
|
|
|
|
|
|
856 => 'LA', |
186
|
|
|
|
|
|
|
86 => 'CN', |
187
|
|
|
|
|
|
|
870 => 'XN', |
188
|
|
|
|
|
|
|
871 => 'XE', |
189
|
|
|
|
|
|
|
872 => 'XF', |
190
|
|
|
|
|
|
|
873 => 'XI', |
191
|
|
|
|
|
|
|
874 => 'XW', |
192
|
|
|
|
|
|
|
878 => 'XP', |
193
|
|
|
|
|
|
|
880 => 'BD', |
194
|
|
|
|
|
|
|
881 => 'XG', |
195
|
|
|
|
|
|
|
882 => 'XV', |
196
|
|
|
|
|
|
|
886 => 'TW', |
197
|
|
|
|
|
|
|
90 => 'TR', |
198
|
|
|
|
|
|
|
91 => 'IN', |
199
|
|
|
|
|
|
|
92 => 'PK', |
200
|
|
|
|
|
|
|
93 => 'AF', |
201
|
|
|
|
|
|
|
94 => 'LK', |
202
|
|
|
|
|
|
|
95 => 'MM', |
203
|
|
|
|
|
|
|
960 => 'MV', |
204
|
|
|
|
|
|
|
961 => 'LB', |
205
|
|
|
|
|
|
|
962 => 'JO', |
206
|
|
|
|
|
|
|
963 => 'SY', |
207
|
|
|
|
|
|
|
964 => 'IQ', |
208
|
|
|
|
|
|
|
965 => 'KW', |
209
|
|
|
|
|
|
|
966 => 'SA', |
210
|
|
|
|
|
|
|
967 => 'YE', |
211
|
|
|
|
|
|
|
968 => 'OM', |
212
|
|
|
|
|
|
|
970 => 'PS', |
213
|
|
|
|
|
|
|
971 => 'AE', |
214
|
|
|
|
|
|
|
972 => 'IL', |
215
|
|
|
|
|
|
|
973 => 'BH', |
216
|
|
|
|
|
|
|
974 => 'QA', |
217
|
|
|
|
|
|
|
975 => 'BT', |
218
|
|
|
|
|
|
|
976 => 'MN', |
219
|
|
|
|
|
|
|
977 => 'NP', |
220
|
|
|
|
|
|
|
979 => 'XR', |
221
|
|
|
|
|
|
|
98 => 'IR', |
222
|
|
|
|
|
|
|
991 => 'XC', |
223
|
|
|
|
|
|
|
992 => 'TJ', |
224
|
|
|
|
|
|
|
993 => 'TM', |
225
|
|
|
|
|
|
|
994 => 'AZ', |
226
|
|
|
|
|
|
|
995 => 'GE', |
227
|
|
|
|
|
|
|
996 => 'KG', |
228
|
|
|
|
|
|
|
998 => 'UZ', |
229
|
|
|
|
|
|
|
); |
230
|
|
|
|
|
|
|
our %ISO3166_DIALING = map { my $dc = $_; my $x = $DIALING_ISO3166{$_}; map { $_ => $dc } (ref($x) ? @{$x} : $x); } keys(%DIALING_ISO3166); |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
sub new { |
234
|
1
|
|
|
1
|
1
|
400
|
my $proto = shift; |
235
|
1
|
|
33
|
|
|
8
|
my $class = ref($proto) || $proto; |
236
|
1
|
|
|
|
|
3
|
my $self = {}; |
237
|
1
|
|
|
|
|
3
|
bless($self,$class); |
238
|
1
|
|
|
|
|
3
|
return $self; |
239
|
|
|
|
|
|
|
} |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
sub country_codes { |
244
|
2
|
|
|
2
|
1
|
4
|
my $proto = shift; |
245
|
2
|
|
|
|
|
4
|
my $dc = shift; |
246
|
2
|
|
|
|
|
4
|
my $cc = $DIALING_ISO3166{$dc}; |
247
|
2
|
50
|
|
|
|
6
|
if (defined($cc)) { |
248
|
2
|
100
|
|
|
|
15
|
return ref($cc) ? @{$cc} : ($cc); |
|
1
|
|
|
|
|
14
|
|
249
|
|
|
|
|
|
|
} |
250
|
0
|
|
|
|
|
0
|
return (); |
251
|
|
|
|
|
|
|
} |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
sub dialing_code { |
256
|
2
|
|
|
2
|
1
|
552
|
my $proto = shift; |
257
|
2
|
|
|
|
|
5
|
my $cc = uc(shift); |
258
|
2
|
|
|
|
|
12
|
return $ISO3166_DIALING{$cc}; |
259
|
|
|
|
|
|
|
} |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
sub extract_dialing_code { |
264
|
1
|
|
|
1
|
1
|
271
|
my $proto = shift; |
265
|
1
|
|
|
|
|
3
|
my $phn = shift; |
266
|
|
|
|
|
|
|
# Chop off leading + or 0's if any. |
267
|
1
|
|
|
|
|
4
|
$phn =~ s/^[+0]+//; |
268
|
1
|
|
|
|
|
27
|
foreach my $dialcode (keys %DIALING_ISO3166) { |
269
|
140
|
100
|
|
|
|
307
|
if (substr($phn,0,length($dialcode)) eq $dialcode) { |
270
|
1
|
|
|
|
|
5
|
return $dialcode; |
271
|
|
|
|
|
|
|
} |
272
|
|
|
|
|
|
|
} |
273
|
0
|
|
|
|
|
|
return undef; |
274
|
|
|
|
|
|
|
} |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
1; |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
__END__ |