line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Number::Phone::JP; |
2
|
|
|
|
|
|
|
|
3
|
22
|
|
|
22
|
|
246317
|
use strict; |
|
22
|
|
|
|
|
56
|
|
|
22
|
|
|
|
|
747
|
|
4
|
22
|
|
|
22
|
|
111
|
use warnings; |
|
22
|
|
|
|
|
36
|
|
|
22
|
|
|
|
|
524
|
|
5
|
22
|
|
|
22
|
|
382
|
use 5.008_001; |
|
22
|
|
|
|
|
74
|
|
6
|
22
|
|
|
22
|
|
8374
|
use parent qw(Number::Phone); |
|
22
|
|
|
|
|
5833
|
|
|
22
|
|
|
|
|
97
|
|
7
|
22
|
|
|
22
|
|
507679
|
use Carp; |
|
22
|
|
|
|
|
49
|
|
|
22
|
|
|
|
|
1266
|
|
8
|
22
|
|
|
22
|
|
8559
|
use UNIVERSAL::require; |
|
22
|
|
|
|
|
20377
|
|
|
22
|
|
|
|
|
181
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.20190521'; |
11
|
|
|
|
|
|
|
our %TEL_TABLE = (); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub import { |
14
|
89
|
|
|
89
|
|
17257
|
my $self = shift; |
15
|
89
|
|
|
|
|
1918
|
%TEL_TABLE = (); |
16
|
89
|
100
|
|
|
|
516
|
if (@_) { |
17
|
14
|
|
|
|
|
38
|
for my $subclass (@_) { |
18
|
15
|
|
|
|
|
36
|
my $package = _table_class_name($subclass); |
19
|
15
|
50
|
|
|
|
85
|
$package->require or croak $@; |
20
|
|
|
|
|
|
|
{ |
21
|
22
|
|
|
22
|
|
1806
|
no strict 'refs'; |
|
22
|
|
|
|
|
46
|
|
|
22
|
|
|
|
|
12927
|
|
|
15
|
|
|
|
|
179
|
|
22
|
15
|
|
|
|
|
28
|
while (my($k, $v) = each %{"$package\::TEL_TABLE"}) { |
|
459
|
|
|
|
|
1200
|
|
23
|
444
|
100
|
|
|
|
620
|
if ($TEL_TABLE{$k}) { |
24
|
|
|
|
|
|
|
$TEL_TABLE{$k} = |
25
|
1
|
|
|
|
|
3
|
'(?:' . $TEL_TABLE{$k} . '|' . $v . ')'; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
else { |
28
|
443
|
|
|
|
|
646
|
$TEL_TABLE{$k} = $v; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
else { |
35
|
75
|
|
|
|
|
3399
|
require Number::Phone::JP::Table; |
36
|
75
|
|
|
|
|
233
|
import Number::Phone::JP::Table; |
37
|
|
|
|
|
|
|
} |
38
|
89
|
|
|
|
|
3060
|
return $self; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub new { |
42
|
82
|
|
|
82
|
1
|
7449
|
my $class = shift; |
43
|
82
|
|
|
|
|
200
|
my $self = bless {}, $class; |
44
|
82
|
100
|
|
|
|
314
|
$self->set_number(@_) if @_; |
45
|
82
|
|
|
|
|
375
|
return $self; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub set_number { |
49
|
66219
|
|
|
66219
|
1
|
372633
|
my $self = shift; |
50
|
66219
|
|
|
|
|
90463
|
my $number = shift; |
51
|
66219
|
50
|
|
|
|
395601
|
if (ref($number) eq 'ARRAY') { |
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
52
|
0
|
|
|
|
|
0
|
$self->_prefix = shift @$number; |
53
|
0
|
|
|
|
|
0
|
(my $num = join('', @$number)) =~ s/\D+//g; |
54
|
0
|
|
|
|
|
0
|
$self->_number = $num; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
elsif (defined $_[0]) { |
57
|
0
|
|
|
|
|
0
|
$self->_prefix = $number; |
58
|
0
|
|
|
|
|
0
|
(my $num = join('', @_)) =~ s/\D+//g; |
59
|
0
|
|
|
|
|
0
|
$self->_number = $num; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
elsif ($number =~ /^\D*(0\d+)\D(.+)$/) { |
62
|
66152
|
|
|
|
|
127270
|
my $pref = $1; |
63
|
66152
|
|
|
|
|
100851
|
my $num = $2; |
64
|
66152
|
|
|
|
|
118252
|
$pref =~ s/\D+//g; |
65
|
66152
|
|
|
|
|
84328
|
$num =~ s/\D+//g; |
66
|
66152
|
|
|
|
|
132207
|
$self->_prefix = $pref; |
67
|
66152
|
|
|
|
|
105328
|
$self->_number = $num; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
elsif ($number =~ s/^\+81//) { |
70
|
67
|
|
|
|
|
132
|
$self->_prefix = (); |
71
|
67
|
|
|
|
|
108
|
$self->_number = (); |
72
|
67
|
|
|
|
|
167
|
for (my $i = 1; $i < length $number; $i++) { |
73
|
597
|
|
|
|
|
770
|
my $pref = substr $number, 0, $i; |
74
|
597
|
100
|
|
|
|
1101
|
if ($TEL_TABLE{$pref}) { |
75
|
79
|
|
|
|
|
131
|
$self->_prefix = "0$pref"; |
76
|
79
|
|
|
|
|
127
|
$self->_number = substr $number, $i; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
else { |
81
|
0
|
|
|
|
|
0
|
carp "The number is invalid telephone number."; |
82
|
0
|
|
|
|
|
0
|
$self->_prefix = (); |
83
|
0
|
|
|
|
|
0
|
$self->_number = (); |
84
|
|
|
|
|
|
|
} |
85
|
66219
|
|
|
|
|
221376
|
return $self; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub is_valid_number { |
89
|
66163
|
|
|
66163
|
1
|
86053
|
my $self = shift; |
90
|
66163
|
50
|
33
|
|
|
104400
|
unless ($self->_prefix || $self->_number) { |
91
|
0
|
|
|
|
|
0
|
carp "Any number was not set"; |
92
|
0
|
|
|
|
|
0
|
return; |
93
|
|
|
|
|
|
|
} |
94
|
66163
|
|
|
|
|
93990
|
my $pref = $self->_prefix; |
95
|
66163
|
50
|
|
|
|
204172
|
return unless $pref =~ s/^0//; |
96
|
66163
|
|
|
|
|
132019
|
my $re = $TEL_TABLE{$pref}; |
97
|
66163
|
100
|
|
|
|
106683
|
return unless defined $re; |
98
|
65942
|
|
|
|
|
100728
|
return $self->_number =~ /^$re$/; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
198749
|
|
|
198749
|
|
336451
|
sub _prefix : lvalue { shift->{_prefix} } |
102
|
132253
|
|
|
132253
|
|
672494
|
sub _number : lvalue { shift->{_number} } |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
{ |
105
|
22
|
|
|
22
|
|
192
|
no warnings 'once'; |
|
22
|
|
|
|
|
51
|
|
|
22
|
|
|
|
|
2901
|
|
106
|
|
|
|
|
|
|
*is_valid = \&is_valid_number; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub _table_class_name { |
110
|
127
|
|
|
127
|
|
158
|
my $subclass = shift; |
111
|
127
|
|
|
|
|
689
|
return sprintf('%s::Table::%s', __PACKAGE__, ucfirst(lc($subclass))); |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub _is_this_type { |
115
|
110
|
|
|
110
|
|
176
|
my($self, $type) = @_; |
116
|
110
|
|
|
|
|
172
|
my $package = _table_class_name($type); |
117
|
110
|
|
|
|
|
406
|
$package->require; |
118
|
110
|
|
|
|
|
2992
|
my $pref = $self->_prefix; |
119
|
110
|
|
|
|
|
261
|
$pref =~ s/^0//; |
120
|
22
|
|
|
22
|
|
143
|
no strict 'refs'; |
|
22
|
|
|
|
|
41
|
|
|
22
|
|
|
|
|
3000
|
|
121
|
110
|
|
|
|
|
149
|
return exists ${"$package\::TEL_TABLE"}{$pref}; |
|
110
|
|
|
|
|
577
|
|
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub is_mobile { |
125
|
22
|
|
|
22
|
1
|
34
|
my $self = shift; |
126
|
22
|
|
|
|
|
60
|
my $result = $self->_is_this_type('mobile'); |
127
|
22
|
100
|
|
|
|
90
|
return $result unless $result; |
128
|
4
|
|
|
|
|
18
|
my $pref = $self->_prefix; |
129
|
4
|
|
|
|
|
12
|
$pref =~ s/^0//; |
130
|
4
|
100
|
|
|
|
18
|
return $result if $pref ne '70'; |
131
|
2
|
|
|
|
|
5
|
my $package = _table_class_name('mobile'); |
132
|
22
|
|
|
22
|
|
156
|
no strict 'refs'; |
|
22
|
|
|
|
|
48
|
|
|
22
|
|
|
|
|
8482
|
|
133
|
2
|
|
|
|
|
4
|
my $re = ${"$package\::TEL_TABLE"}{$pref}; |
|
2
|
|
|
|
|
29
|
|
134
|
2
|
|
|
|
|
6
|
return $self->_number =~ /^$re$/; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
22
|
|
|
22
|
1
|
41
|
sub is_pager { return shift->_is_this_type('pager') } |
138
|
22
|
|
|
22
|
1
|
46
|
sub is_ipphone { return shift->_is_this_type('ipphone') } |
139
|
22
|
|
|
22
|
1
|
44
|
sub is_tollfree { return shift->_is_this_type('freedial') } |
140
|
22
|
|
|
22
|
1
|
47
|
sub is_specialrate { return shift->_is_this_type('q2') } |
141
|
|
|
|
|
|
|
|
142
|
1
|
|
|
1
|
1
|
11
|
sub is_allocated { undef } |
143
|
1
|
|
|
1
|
1
|
299
|
sub is_in_use { undef } |
144
|
1
|
|
|
1
|
1
|
287
|
sub is_geographic { undef } |
145
|
1
|
|
|
1
|
1
|
322
|
sub is_fixed_line { undef } |
146
|
1
|
|
|
1
|
1
|
283
|
sub is_isdn { undef } |
147
|
1
|
|
|
1
|
1
|
294
|
sub is_adult { undef } |
148
|
1
|
|
|
1
|
1
|
283
|
sub is_personal { undef } |
149
|
1
|
|
|
1
|
1
|
282
|
sub is_corporate { undef } |
150
|
1
|
|
|
1
|
1
|
380
|
sub is_government { undef } |
151
|
1
|
|
|
1
|
1
|
286
|
sub is_international { undef } |
152
|
1
|
|
|
1
|
1
|
282
|
sub is_network_service { undef } |
153
|
|
|
|
|
|
|
|
154
|
22
|
|
|
22
|
1
|
60
|
sub country_code { return 81 } |
155
|
|
|
|
|
|
|
|
156
|
1
|
|
|
1
|
1
|
281
|
sub regulator { undef } |
157
|
1
|
|
|
1
|
1
|
280
|
sub areacode { undef } |
158
|
1
|
|
|
1
|
1
|
280
|
sub areaname { undef } |
159
|
1
|
|
|
1
|
1
|
281
|
sub location { undef } |
160
|
1
|
|
|
1
|
1
|
278
|
sub subscriber { undef } |
161
|
1
|
|
|
1
|
1
|
302
|
sub operator { undef } |
162
|
1
|
|
|
1
|
1
|
284
|
sub type { undef } |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
sub format { |
165
|
11
|
|
|
11
|
1
|
19
|
my $self = shift; |
166
|
11
|
|
|
|
|
21
|
my $pref = $self->_prefix; |
167
|
11
|
|
|
|
|
45
|
$pref =~ s/^0//; |
168
|
11
|
|
|
|
|
23
|
return sprintf '+%s %s %s', $self->country_code, $pref, $self->_number; |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
1
|
|
|
1
|
1
|
278
|
sub country { undef } |
172
|
1
|
|
|
1
|
1
|
292
|
sub translates_to { undef } |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
1; |
175
|
|
|
|
|
|
|
__END__ |