line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Number::Phone::CountryCode; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
2001
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
89
|
|
4
|
2
|
|
|
2
|
|
9
|
use base qw(Class::Accessor); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1983
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
__PACKAGE__->mk_ro_accessors(qw(country |
7
|
|
|
|
|
|
|
country_code |
8
|
|
|
|
|
|
|
idd_prefix |
9
|
|
|
|
|
|
|
ndd_prefix)); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# Codes hash |
14
|
|
|
|
|
|
|
# ISO code maps to 3 element array containing: |
15
|
|
|
|
|
|
|
# Country prefix |
16
|
|
|
|
|
|
|
# IDD prefix |
17
|
|
|
|
|
|
|
# NDD prefix |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my %Codes = ( |
20
|
|
|
|
|
|
|
AD => ['376', '00', undef], # Andorra |
21
|
|
|
|
|
|
|
AE => ['971', '00', '0'], # United Arab Emirates |
22
|
|
|
|
|
|
|
AF => [ '93', '00', '0'], # Afghanistan |
23
|
|
|
|
|
|
|
AG => [ '1', '011', '1'], # Antigua and Barbuda |
24
|
|
|
|
|
|
|
AG => [ '1', '011', '1'], # Antigua and Barbuda |
25
|
|
|
|
|
|
|
AI => [ '1', '011', '1'], # Anguilla |
26
|
|
|
|
|
|
|
AL => ['355', '00', '0'], # Albania |
27
|
|
|
|
|
|
|
AM => ['374', '00', '8'], # Armenia |
28
|
|
|
|
|
|
|
AN => ['599', '00', '0'], # Netherlands Antilles |
29
|
|
|
|
|
|
|
AO => ['244', '00', '0'], # Angola |
30
|
|
|
|
|
|
|
AQ => ['672', undef, undef], # Antarctica |
31
|
|
|
|
|
|
|
AR => [ '54', '00', '0'], # Argentina |
32
|
|
|
|
|
|
|
AS => [ '1', '011', '1'], # American Samoa |
33
|
|
|
|
|
|
|
AT => [ '43', '00', '0'], # Austria |
34
|
|
|
|
|
|
|
AU => [ '61', '00', undef], # Australia |
35
|
|
|
|
|
|
|
AW => ['297', '00', undef], # Aruba |
36
|
|
|
|
|
|
|
AZ => ['994', '00', '8'], # Azerbaijan |
37
|
|
|
|
|
|
|
BA => ['387', '00', '0'], # Bosnia and Herzegovina |
38
|
|
|
|
|
|
|
BB => [ '1', '011', '1'], # Barbados |
39
|
|
|
|
|
|
|
BD => ['880', '00', '0'], # Bangladesh |
40
|
|
|
|
|
|
|
BE => [ '32', '00', '0'], # Belgium |
41
|
|
|
|
|
|
|
BF => ['226', '00', undef], # Burkina Faso |
42
|
|
|
|
|
|
|
BG => ['359', '00', '0'], # Bulgaria |
43
|
|
|
|
|
|
|
BH => ['973', '00', undef], # Bahrain |
44
|
|
|
|
|
|
|
BI => ['257', '00', undef], # Burundi |
45
|
|
|
|
|
|
|
BJ => ['229', '00', undef], # Benin |
46
|
|
|
|
|
|
|
BM => [ '1', '011', '1'], # Bermuda |
47
|
|
|
|
|
|
|
BN => ['673', '00', '0'], # Brunei Darussalam |
48
|
|
|
|
|
|
|
BO => ['591', '00', '0'], # Bolivia |
49
|
|
|
|
|
|
|
BR => [ '55', '00', '0'], # Brazil |
50
|
|
|
|
|
|
|
BS => [ '1', '011', '1'], # Bahamas |
51
|
|
|
|
|
|
|
BT => ['975', '00', undef], # Bhutan |
52
|
|
|
|
|
|
|
BW => ['267', '00', undef], # Botswana |
53
|
|
|
|
|
|
|
BY => ['375', '810', '8'], # Belarus (IDD really 8**10) |
54
|
|
|
|
|
|
|
BZ => ['501', '00', '0'], # Belize |
55
|
|
|
|
|
|
|
CA => [ '1', '011', '1'], # Canada |
56
|
|
|
|
|
|
|
CD => ['243', '00', undef], # Congo (Dem. Rep. of / Zaire) |
57
|
|
|
|
|
|
|
CF => ['236', '00', undef], # Central African Republic |
58
|
|
|
|
|
|
|
CH => [ '41', '00', '0'], # Switzerland |
59
|
|
|
|
|
|
|
CI => ['225', '00', '0'], # Cote D'Ivoire |
60
|
|
|
|
|
|
|
CL => [ '56', '00', '0'], # Chile |
61
|
|
|
|
|
|
|
CM => ['237', '00', undef], # Cameroon |
62
|
|
|
|
|
|
|
CN => [ '86', '00', '0'], # China |
63
|
|
|
|
|
|
|
CO => [ '57', '009', '09'], # Colombia |
64
|
|
|
|
|
|
|
CR => ['506', '00', undef], # Costa Rica |
65
|
|
|
|
|
|
|
CV => ['238', '0', undef], # Cape Verde Islands |
66
|
|
|
|
|
|
|
CX => [ '61', '0011', '0'], # Christmas Island |
67
|
|
|
|
|
|
|
CY => ['357', '00', undef], # Cyprus |
68
|
|
|
|
|
|
|
CZ => ['420', '00', undef], # Czech Republic |
69
|
|
|
|
|
|
|
DE => [ '49', '00', '0'], # Germany |
70
|
|
|
|
|
|
|
DJ => ['253', '00', undef], # Djibouti |
71
|
|
|
|
|
|
|
DK => [ '45', '00', undef], # Denmark |
72
|
|
|
|
|
|
|
DO => [ '1', '011', 1], # Dominican Republic |
73
|
|
|
|
|
|
|
DZ => ['213', '00', '7'], # Algeria |
74
|
|
|
|
|
|
|
EC => ['593', '00', '0'], # Ecuador |
75
|
|
|
|
|
|
|
EE => ['372', '00', undef], # Estonia |
76
|
|
|
|
|
|
|
EG => [ '20', '00', '0'], # Egypt |
77
|
|
|
|
|
|
|
EH => ['212', '00', '0'], # Western Sahara |
78
|
|
|
|
|
|
|
ER => ['291', '00', '0'], # Eritrea |
79
|
|
|
|
|
|
|
ET => ['251', '00', '0'], # Ethiopia |
80
|
|
|
|
|
|
|
FI => ['358', '00', '0'], # Finland |
81
|
|
|
|
|
|
|
FJ => ['679', '00', undef], # Fiji |
82
|
|
|
|
|
|
|
FK => ['500', '00', undef], # Falkland Islands (Malvinas) |
83
|
|
|
|
|
|
|
FM => ['691', '011', '1'], # Micronesia, Federated States of |
84
|
|
|
|
|
|
|
FO => ['298', '00', undef], # Faroe Islands |
85
|
|
|
|
|
|
|
FR => [ '33', '00', undef], # France |
86
|
|
|
|
|
|
|
GA => ['241', '00', undef], # Gabonese Republic |
87
|
|
|
|
|
|
|
GB => [ '44', '00', '0'], # United Kingdom |
88
|
|
|
|
|
|
|
GD => [ '1', '011', '4'], # Grenada |
89
|
|
|
|
|
|
|
GF => ['594', '00', undef], # French Guiana |
90
|
|
|
|
|
|
|
GH => ['233', '00', undef], # Ghana |
91
|
|
|
|
|
|
|
GI => ['350', '00', undef], # Gibraltar |
92
|
|
|
|
|
|
|
GL => ['299', '00', undef], # Greenland |
93
|
|
|
|
|
|
|
GM => ['220', '00', undef], # Gambia |
94
|
|
|
|
|
|
|
GP => ['590', '00', undef], # Guadeloupe |
95
|
|
|
|
|
|
|
GQ => ['240', '00', undef], # Equatorial Guinea |
96
|
|
|
|
|
|
|
GR => [ '30', '00', undef], # Greece |
97
|
|
|
|
|
|
|
GS => ['995', '810', '8'], # South Georgia and the South Sandwich Islands (IDD really 8**10) |
98
|
|
|
|
|
|
|
GT => ['502', '00', undef], # Guatemala |
99
|
|
|
|
|
|
|
GW => ['245', '00', undef], # Guinea-Bissau |
100
|
|
|
|
|
|
|
HK => ['852', '001', undef], # Hong Kong |
101
|
|
|
|
|
|
|
HN => ['504', '00', '0'], # Honduras |
102
|
|
|
|
|
|
|
HR => ['385', '00', '0'], # Croatia |
103
|
|
|
|
|
|
|
HT => ['509', '00', '0'], # Haiti |
104
|
|
|
|
|
|
|
HU => [ '36', '00', '06'], # Hungary |
105
|
|
|
|
|
|
|
ID => [ '62', '001', '0'], # Indonesia |
106
|
|
|
|
|
|
|
IE => ['353', '00', '0'], # Ireland |
107
|
|
|
|
|
|
|
IL => ['972', '00', '0'], # Israel |
108
|
|
|
|
|
|
|
IN => [ '91', '00', '0'], # India |
109
|
|
|
|
|
|
|
IQ => ['964', '00', '0'], # Iraq |
110
|
|
|
|
|
|
|
IR => [ '98', '00', '0'], # Iran, Islamic Republic of |
111
|
|
|
|
|
|
|
IT => [ '39', '00', undef], # Italy |
112
|
|
|
|
|
|
|
JM => [ '1', '011', '1'], # Jamaica |
113
|
|
|
|
|
|
|
JO => ['962', '00', '0'], # Jordan |
114
|
|
|
|
|
|
|
JP => [ '81', '001', '0'], # Japan |
115
|
|
|
|
|
|
|
KE => ['254', '000', '0'], # Kenya |
116
|
|
|
|
|
|
|
KG => ['996', '00', '0'], # Kyrgyzstan |
117
|
|
|
|
|
|
|
KH => ['855', '001', '0'], # Cambodia |
118
|
|
|
|
|
|
|
KI => ['686', '00', '0'], # Kiribati |
119
|
|
|
|
|
|
|
KM => ['269', '00', undef], # Comoros |
120
|
|
|
|
|
|
|
KN => [ '1', '011', '1'], # Saint Kitts and Nevis |
121
|
|
|
|
|
|
|
KP => ['850', '00', '0'], # Korea, Democratic People's Republic of |
122
|
|
|
|
|
|
|
KR => [ '82', '001', '0'], # Korea (South) |
123
|
|
|
|
|
|
|
KW => ['965', '00', '0'], # Kuwait |
124
|
|
|
|
|
|
|
KY => [ '1', '011', '1'], # Cayman Islands |
125
|
|
|
|
|
|
|
KZ => [ '7', '810', '8'], # Kazakhstan (IDD really 8**10) |
126
|
|
|
|
|
|
|
LB => ['961', '00', '0'], # Lebanon |
127
|
|
|
|
|
|
|
LC => [ '1', '011', '1'], # Saint Lucia |
128
|
|
|
|
|
|
|
LI => ['423', '00', undef], # Liechtenstein |
129
|
|
|
|
|
|
|
LK => [ '94', '00', '0'], # Sri Lanka |
130
|
|
|
|
|
|
|
LR => ['231', '00', '22'], # Liberia |
131
|
|
|
|
|
|
|
LS => ['266', '00', '0'], # Lesotho |
132
|
|
|
|
|
|
|
LT => ['370', '00', '8'], # Lithuania |
133
|
|
|
|
|
|
|
LU => ['352', '00', undef], # Luxembourg |
134
|
|
|
|
|
|
|
LV => ['371', '00', '8'], # Latvia |
135
|
|
|
|
|
|
|
LY => ['218', '00', '0'], # Libyan Arab Jamahiriya |
136
|
|
|
|
|
|
|
MA => ['212', '00', undef], # Morocco |
137
|
|
|
|
|
|
|
MC => ['377', '00', '0'], # Monaco |
138
|
|
|
|
|
|
|
MD => ['373', '00', '0'], # Moldova, Republic of |
139
|
|
|
|
|
|
|
MG => ['261', '00', '0'], # Madagascar |
140
|
|
|
|
|
|
|
MH => ['692', '011', '1'], # Marshall Islands |
141
|
|
|
|
|
|
|
MK => ['389', '00', '0'], # Macedonia, the Former Yugoslav Republic of |
142
|
|
|
|
|
|
|
MN => ['976', '001', '0'], # Mongolia |
143
|
|
|
|
|
|
|
MO => ['853', '00', '0'], # Macao |
144
|
|
|
|
|
|
|
MP => [ '1', '011', '1'], # Northern Mariana Islands |
145
|
|
|
|
|
|
|
MQ => ['596', '00', '0'], # Martinique |
146
|
|
|
|
|
|
|
MR => ['222', '00', '0'], # Mauritania |
147
|
|
|
|
|
|
|
MS => [ '1', '011', '1'], # Montserrat |
148
|
|
|
|
|
|
|
MU => ['230', '00', '0'], # Mauritius |
149
|
|
|
|
|
|
|
MV => ['960', '00', '0'], # Maldives |
150
|
|
|
|
|
|
|
MW => ['265', '00', undef], # Malawi |
151
|
|
|
|
|
|
|
MX => [ '52', '00', '01'], # Mexico |
152
|
|
|
|
|
|
|
MY => [ '60', '00', '0'], # Malaysia |
153
|
|
|
|
|
|
|
MZ => ['258', '00', '0'], # Mozambique |
154
|
|
|
|
|
|
|
NA => ['264', '00', '0'], # Namibia |
155
|
|
|
|
|
|
|
NC => ['687', '00', '0'], # New Caledonia |
156
|
|
|
|
|
|
|
NE => ['227', '00', '0'], # Niger |
157
|
|
|
|
|
|
|
NF => ['672', '00', undef], # Norfolk Island |
158
|
|
|
|
|
|
|
NG => ['234', '009', '0'], # Nigeria |
159
|
|
|
|
|
|
|
NI => ['505', '00', '0'], # Nicaragua |
160
|
|
|
|
|
|
|
NL => [ '31', '00', '0'], # Netherlands |
161
|
|
|
|
|
|
|
NO => [ '47', '00', undef], # Norway |
162
|
|
|
|
|
|
|
NR => ['674', '00', '0'], # Nauru |
163
|
|
|
|
|
|
|
NU => ['683', '00', '0'], # Niue |
164
|
|
|
|
|
|
|
NZ => [ '64', '00', '0'], # New Zealand |
165
|
|
|
|
|
|
|
PA => ['507', '00', '0'], # Panama |
166
|
|
|
|
|
|
|
PE => [ '51', '00', '0'], # Peru |
167
|
|
|
|
|
|
|
PF => ['689', '00', undef], # French Polynesia |
168
|
|
|
|
|
|
|
PG => ['675', '05', undef], # Papua New Guinea |
169
|
|
|
|
|
|
|
PH => [ '63', '00', '0'], # Philippines |
170
|
|
|
|
|
|
|
PK => [ '92', '00', '0'], # Pakistan |
171
|
|
|
|
|
|
|
PL => [ '48', '00', '0'], # Poland |
172
|
|
|
|
|
|
|
PM => ['508', '00', '0'], # Saint Pierre and Miquelon |
173
|
|
|
|
|
|
|
PR => [ '1', '011', '1'], # Puerto Rico |
174
|
|
|
|
|
|
|
PS => ['970', '00', '0'], # Palestinian Territory, Occupied |
175
|
|
|
|
|
|
|
PT => ['351', '00', undef], # Portugal |
176
|
|
|
|
|
|
|
PW => ['680', '011', undef], # Palau |
177
|
|
|
|
|
|
|
PY => ['595', '002', '0'], # Paraguay |
178
|
|
|
|
|
|
|
QA => ['974', '00', '0'], # Qatar |
179
|
|
|
|
|
|
|
RE => ['262', '00', '0'], # Reunion |
180
|
|
|
|
|
|
|
RO => [ '40', '00', '0'], # Romania |
181
|
|
|
|
|
|
|
RS => ['381', '99', '0'], # Serbia |
182
|
|
|
|
|
|
|
RW => ['250', '00', '0'], # Rwanda |
183
|
|
|
|
|
|
|
SA => ['966', '00', '0'], # Saudi Arabia |
184
|
|
|
|
|
|
|
SB => ['677', '00', undef], # Solomon Islands |
185
|
|
|
|
|
|
|
SC => ['248', '00', '0'], # Seychelles |
186
|
|
|
|
|
|
|
SD => ['249', '00', '0'], # Sudan |
187
|
|
|
|
|
|
|
SE => [ '46', '00', '0'], # Sweden |
188
|
|
|
|
|
|
|
SG => [ '65', '001', undef], # Singapore |
189
|
|
|
|
|
|
|
SH => ['290', '00', undef], # Saint Helena |
190
|
|
|
|
|
|
|
SI => ['386', '00', '0'], # Slovenia |
191
|
|
|
|
|
|
|
SK => ['421', '00', '0'], # Slovakia |
192
|
|
|
|
|
|
|
SL => ['232', '00', '0'], # Sierra Leone |
193
|
|
|
|
|
|
|
SM => ['378', '00', '0'], # San Marino |
194
|
|
|
|
|
|
|
SN => ['221', '00', '0'], # Senegal |
195
|
|
|
|
|
|
|
SO => ['252', '00', undef], # Somalia |
196
|
|
|
|
|
|
|
SR => ['597', '00', undef], # Suriname |
197
|
|
|
|
|
|
|
ST => ['239', '00', '0'], # Sao Tome and Principe |
198
|
|
|
|
|
|
|
SV => ['503', '00', undef], # El Salvador |
199
|
|
|
|
|
|
|
SZ => ['268', '00', undef], # Swaziland |
200
|
|
|
|
|
|
|
TC => [ '1', '011', '1'], # Turks and Caicos Islands |
201
|
|
|
|
|
|
|
TD => ['235', '15', undef], # Chad |
202
|
|
|
|
|
|
|
TG => ['228', '00', undef], # Togo |
203
|
|
|
|
|
|
|
TH => [ '66', '001', '0'], # Thailand |
204
|
|
|
|
|
|
|
TJ => ['992', '810', '8'], # Tajikistan (IDD really 8**10) |
205
|
|
|
|
|
|
|
TK => ['690', '00', undef], # Tokelau |
206
|
|
|
|
|
|
|
TL => ['670', '00', undef], # Timor-Leste |
207
|
|
|
|
|
|
|
TM => ['993', '810', '8'], # Turkmenistan (IDD really 8**10) |
208
|
|
|
|
|
|
|
TN => ['216', '00', '0'], # Tunisia |
209
|
|
|
|
|
|
|
TR => [ '90', '00', '0'], # Turkey |
210
|
|
|
|
|
|
|
TT => [ '1', '011', '1'], # Trinidad and Tobago |
211
|
|
|
|
|
|
|
TV => ['688', '00', undef], # Tuvalu |
212
|
|
|
|
|
|
|
TW => ['886', '002', undef], # Taiwan, Province of China |
213
|
|
|
|
|
|
|
TZ => ['255', '000', '0'], # Tanzania, United Republic of |
214
|
|
|
|
|
|
|
UA => ['380', '810', '8'], # Ukraine (IDD really 8**10) |
215
|
|
|
|
|
|
|
UG => ['256', '000', '0'], # Uganda |
216
|
|
|
|
|
|
|
US => [ '1', '011', '1'], # United States |
217
|
|
|
|
|
|
|
UY => ['598', '00', '0'], # Uruguay |
218
|
|
|
|
|
|
|
UZ => ['998', '810', '8'], # Uzbekistan (IDD really 8**10) |
219
|
|
|
|
|
|
|
VA => ['379', '00', undef], # Holy See (Vatican City State) |
220
|
|
|
|
|
|
|
VC => [ '1', '011', '1'], # Saint Vincent and the Grenadines |
221
|
|
|
|
|
|
|
VE => [ '58', '00', '0'], # Venezuela |
222
|
|
|
|
|
|
|
VG => [ '1', '011', '1'], # Virgin Islands, British |
223
|
|
|
|
|
|
|
VI => [ '1', '011', '1'], # Virgin Islands, U.S. |
224
|
|
|
|
|
|
|
VN => [ '84', '00', '0'], # Viet Nam |
225
|
|
|
|
|
|
|
VU => ['678', '00', undef], # Vanuatu |
226
|
|
|
|
|
|
|
WF => ['681', '19', undef], # Wallis and Futuna Islands |
227
|
|
|
|
|
|
|
WS => ['685', '0', '0'], # Samoa (Western) |
228
|
|
|
|
|
|
|
YE => ['967', '00', '0'], # Yemen |
229
|
|
|
|
|
|
|
YT => ['269', '00', undef], # Mayotte |
230
|
|
|
|
|
|
|
ZA => [ '27', '09', '0'], # South Africa |
231
|
|
|
|
|
|
|
ZW => ['263', '110', '0'], # Zimbabwe |
232
|
|
|
|
|
|
|
); |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=head1 NAME |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
Number::Phone::CountryCode - Country phone dialing prefixes |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=head1 SYNOPSIS |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
use Number::Phone::CountryCode; |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
# retrieve object of United Kingdom codes. |
243
|
|
|
|
|
|
|
my $pc = Number::Phone::CountryCode->new('GB'); |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
print $pc->country; # ISO 3166 code, e.g: GB |
246
|
|
|
|
|
|
|
print $pc->country_code; # country prefix |
247
|
|
|
|
|
|
|
print $pc->idd_prefix; # IDD prefix |
248
|
|
|
|
|
|
|
print $pc->ndd_prefix; # NDD prefix |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
# get list of supported ISO 3166 codes |
251
|
|
|
|
|
|
|
my @countries = Number::Phone::CountryCode->countries; |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
See below for description of the country/IDD/NDD prefixes. |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=head1 DESCRIPTION |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
This module provides an interface to lookup country specific dialing prefixes. |
258
|
|
|
|
|
|
|
These prefixes are useful when working with phone numbers from different |
259
|
|
|
|
|
|
|
countries. The follwing codes are available for each country: |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=head2 Country Code |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
This is the national prefix to be used with dialing B a country B |
264
|
|
|
|
|
|
|
another country. |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
=head2 National Direct Dialing Prefix (NDD) |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
This is the prefix used to make a call B from one city to |
269
|
|
|
|
|
|
|
another. This prefix may not be necessary when calling another city in the |
270
|
|
|
|
|
|
|
same vicinity. This is followed by the city or area code for the place you are |
271
|
|
|
|
|
|
|
calling. For example, in the US, the NDD prefix is "1", so you must dial 1 |
272
|
|
|
|
|
|
|
before the area code to place a long distance call within the country. |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
=head2 International Direct Dialing Prefix (IDD) |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
This is the prefix needed to make a call B to another country. |
277
|
|
|
|
|
|
|
This is followed by the country code for the country you are calling. For |
278
|
|
|
|
|
|
|
example, when calling another country from the US, you must dial 011. |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
=cut |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
=head1 CONSTRUCTOR |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
=over 4 |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
=item new($country) |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
Constructs a new Number::Phone::CountryCode object. C<$country> is the two |
289
|
|
|
|
|
|
|
digit ISO 3166 country code for the country you wish to look up. Returns |
290
|
|
|
|
|
|
|
C if the country code did not match one of the supported countries. |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
=back |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
=cut |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
sub new { |
297
|
212
|
|
|
212
|
1
|
413131
|
my ($class, $country) = @_; |
298
|
|
|
|
|
|
|
|
299
|
212
|
|
|
|
|
420
|
$country = uc $country; |
300
|
|
|
|
|
|
|
|
301
|
212
|
|
|
|
|
540
|
my $data = $Codes{$country}; |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
# return nothing if no data for this country code. |
304
|
212
|
50
|
|
|
|
597
|
return unless defined $data; |
305
|
|
|
|
|
|
|
|
306
|
212
|
|
|
|
|
1785
|
return $class->SUPER::new({ |
307
|
|
|
|
|
|
|
country => $country, |
308
|
|
|
|
|
|
|
country_code => $data->[0], |
309
|
|
|
|
|
|
|
idd_prefix => $data->[1], |
310
|
|
|
|
|
|
|
ndd_prefix => $data->[2] |
311
|
|
|
|
|
|
|
}); |
312
|
|
|
|
|
|
|
} |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
=head1 METHODS |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
The following methods are available |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
=over 4 |
319
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
=item country |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
the ISO 3166 country code for this country |
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
=item country_code |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
The national prefix for this country |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
=item ndd_prefix |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
The NDD prefix for this country. Note that this might be undef if no prefix is |
331
|
|
|
|
|
|
|
necessary. |
332
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
=item idd_prefix |
334
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
The IDD prefix for this country. Note that this might be undef if no prefix is |
336
|
|
|
|
|
|
|
necessary. |
337
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
=back |
339
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
=cut |
341
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
=head1 CLASS METHODS |
343
|
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
The following class methods are available (may be called without constructing |
345
|
|
|
|
|
|
|
an object). |
346
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
=over 4 |
348
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
=item countries |
350
|
|
|
|
|
|
|
|
351
|
|
|
|
|
|
|
Returns a list of all ISO 3166 country codes supported by this module. |
352
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
=cut |
354
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
sub countries { |
356
|
1
|
|
|
1
|
1
|
115
|
return sort keys %Codes; |
357
|
|
|
|
|
|
|
} |
358
|
|
|
|
|
|
|
|
359
|
|
|
|
|
|
|
=item is_supported($country) |
360
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
Returns true if the given country is supported, false otherwise. C<$country> |
362
|
|
|
|
|
|
|
is a 2 character ISO 3166 country code. |
363
|
|
|
|
|
|
|
|
364
|
|
|
|
|
|
|
=cut |
365
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
sub is_supported { |
367
|
2
|
|
|
2
|
1
|
2352
|
my ($class, $code) = @_; |
368
|
|
|
|
|
|
|
|
369
|
2
|
|
|
|
|
4
|
$code = uc $code; |
370
|
|
|
|
|
|
|
|
371
|
2
|
100
|
|
|
|
14
|
return defined $Codes{$code} ? 1 : 0; |
372
|
|
|
|
|
|
|
} |
373
|
|
|
|
|
|
|
|
374
|
|
|
|
|
|
|
=back |
375
|
|
|
|
|
|
|
|
376
|
|
|
|
|
|
|
=cut |
377
|
|
|
|
|
|
|
|
378
|
|
|
|
|
|
|
1; |
379
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
__END__ |