| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Number::ZipCode::JP; |
|
2
|
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
4049615
|
use strict; |
|
|
4
|
|
|
|
|
12
|
|
|
|
4
|
|
|
|
|
896
|
|
|
4
|
4
|
|
|
4
|
|
33
|
use warnings; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
339
|
|
|
5
|
4
|
|
|
4
|
|
100
|
use 5.008_001; |
|
|
4
|
|
|
|
|
18
|
|
|
6
|
4
|
|
|
4
|
|
24
|
use Carp; |
|
|
4
|
|
|
|
|
18
|
|
|
|
4
|
|
|
|
|
412
|
|
|
7
|
4
|
|
|
4
|
|
2758
|
use UNIVERSAL::require; |
|
|
4
|
|
|
|
|
5980
|
|
|
|
4
|
|
|
|
|
945
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.20260227'; |
|
10
|
|
|
|
|
|
|
our %ZIP_TABLE = (); |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub import { |
|
13
|
5
|
|
|
5
|
|
841
|
my $self = shift; |
|
14
|
5
|
|
|
|
|
110
|
%ZIP_TABLE = (); |
|
15
|
5
|
100
|
|
|
|
23
|
if (@_) { |
|
16
|
2
|
|
|
|
|
5
|
my @packages = (); |
|
17
|
2
|
|
|
|
|
7
|
for my $subclass (@_) { |
|
18
|
2
|
|
|
|
|
13
|
push @packages, |
|
19
|
|
|
|
|
|
|
sprintf('%s::Table::%s', __PACKAGE__, ucfirst(lc($subclass))); |
|
20
|
|
|
|
|
|
|
} |
|
21
|
2
|
|
|
|
|
10
|
%ZIP_TABLE = _merge_table(@packages); |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
else { |
|
24
|
3
|
|
|
|
|
982
|
require Number::ZipCode::JP::Table; |
|
25
|
3
|
|
|
|
|
24
|
import Number::ZipCode::JP::Table; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
5
|
|
|
|
|
2429
|
return $self; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub _merge_table { |
|
31
|
4
|
|
|
4
|
|
10
|
my %table = (); |
|
32
|
4
|
|
|
|
|
15
|
for my $pkg (@_) { |
|
33
|
6
|
50
|
|
|
|
55
|
$pkg->require or croak $@; |
|
34
|
|
|
|
|
|
|
{ |
|
35
|
4
|
|
|
4
|
|
33
|
no strict 'refs'; |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
3176
|
|
|
|
6
|
|
|
|
|
105
|
|
|
36
|
6
|
|
|
|
|
71
|
while (my($k, $v) = each %{"$pkg\::ZIP_TABLE"}) { |
|
|
5691
|
|
|
|
|
18131
|
|
|
37
|
5685
|
|
100
|
|
|
16789
|
$table{$k} ||= []; |
|
38
|
5685
|
|
|
|
|
7357
|
push @{$table{$k}}, $v; |
|
|
5685
|
|
|
|
|
11194
|
|
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
} |
|
42
|
4
|
|
|
|
|
2231
|
return %table; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub new { |
|
46
|
3
|
|
|
3
|
1
|
164994
|
my $class = shift; |
|
47
|
3
|
|
|
|
|
9
|
my $self = bless {}, $class; |
|
48
|
3
|
50
|
|
|
|
15
|
$self->set_number(@_) if @_; |
|
49
|
3
|
|
|
|
|
9
|
return $self; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub set_number { |
|
53
|
149136
|
|
|
149136
|
1
|
419880
|
my $self = shift; |
|
54
|
149136
|
|
|
|
|
388182
|
my $number = shift; |
|
55
|
149136
|
50
|
|
|
|
1439113
|
if (ref($number) eq 'ARRAY') { |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
0
|
$self->_prefix = shift @$number; |
|
57
|
0
|
|
|
|
|
0
|
$self->_suffix = shift @$number; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
elsif (defined $_[0]) { |
|
60
|
0
|
|
|
|
|
0
|
$self->_prefix = $number; |
|
61
|
0
|
|
|
|
|
0
|
$self->_suffix = $_[0]; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
elsif ($number =~ /^(\d{3})(?:\D)?(\d{4})$/) { |
|
64
|
149136
|
|
|
|
|
498391
|
my $pref = $1; |
|
65
|
149136
|
|
|
|
|
403337
|
my $suff = $2; |
|
66
|
149136
|
|
|
|
|
516250
|
$self->_prefix = $pref; |
|
67
|
149136
|
|
|
|
|
450791
|
$self->_suffix = $suff; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
else { |
|
70
|
0
|
|
|
|
|
0
|
carp "The number is invalid zip-code."; |
|
71
|
0
|
|
|
|
|
0
|
$self->_prefix = (); |
|
72
|
0
|
|
|
|
|
0
|
$self->_suffix = (); |
|
73
|
|
|
|
|
|
|
} |
|
74
|
149136
|
|
|
|
|
1007184
|
return $self; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub is_valid_number { |
|
78
|
149136
|
|
|
149136
|
1
|
283104
|
my $self = shift; |
|
79
|
149136
|
|
|
|
|
317045
|
my $pref = $self->_prefix; |
|
80
|
149136
|
|
|
|
|
407601
|
my $suff = $self->_suffix; |
|
81
|
149136
|
50
|
33
|
|
|
557409
|
unless ($pref || $suff) { |
|
82
|
0
|
|
|
|
|
0
|
carp "Any number was not set"; |
|
83
|
0
|
|
|
|
|
0
|
return; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
149136
|
50
|
33
|
|
|
1159680
|
return unless $pref =~ /^\d{3}$/ && $suff =~ /^\d{4}$/; |
|
86
|
149136
|
|
|
|
|
616786
|
my $re_ref = $ZIP_TABLE{$pref}; |
|
87
|
149136
|
50
|
33
|
|
|
756763
|
return unless defined $re_ref && ref($re_ref) eq 'ARRAY'; |
|
88
|
149136
|
|
|
|
|
279351
|
my $matched; |
|
89
|
149136
|
|
|
|
|
453505
|
for my $re (@$re_ref) { |
|
90
|
149136
|
100
|
|
|
|
2500079
|
if ($suff =~ /^$re$/) { |
|
91
|
147243
|
|
|
|
|
368677
|
$matched = 1; |
|
92
|
147243
|
|
|
|
|
331109
|
last; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
} |
|
95
|
149136
|
|
|
|
|
1182368
|
return $matched; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
298272
|
|
|
298272
|
|
811903
|
sub _prefix : lvalue { shift->{_prefix} } |
|
99
|
298272
|
|
|
298272
|
|
684729
|
sub _suffix : lvalue { shift->{_suffix} } |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
1; |
|
102
|
|
|
|
|
|
|
__END__ |