line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Parse::JapanesePostalCode; |
2
|
16
|
|
|
16
|
|
447938
|
use strict; |
|
16
|
|
|
|
|
39
|
|
|
16
|
|
|
|
|
378
|
|
3
|
16
|
|
|
16
|
|
74
|
use warnings; |
|
16
|
|
|
|
|
42
|
|
|
16
|
|
|
|
|
373
|
|
4
|
16
|
|
|
16
|
|
1026
|
use utf8; |
|
16
|
|
|
|
|
44
|
|
|
16
|
|
|
|
|
98
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
6
|
|
|
|
|
|
|
|
7
|
16
|
|
|
16
|
|
8960
|
use Parse::JapanesePostalCode::Row; |
|
16
|
|
|
|
|
41
|
|
|
16
|
|
|
|
|
10441
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
17
|
|
|
17
|
1
|
11285892
|
my($class, %opts) = @_; |
11
|
|
|
|
|
|
|
|
12
|
17
|
|
|
|
|
204
|
my $self = bless { |
13
|
|
|
|
|
|
|
format => 'ken', |
14
|
|
|
|
|
|
|
katakana_h2z => 1, |
15
|
|
|
|
|
|
|
alnum_z2h => 1, |
16
|
|
|
|
|
|
|
%opts, |
17
|
|
|
|
|
|
|
current_build_town => '', |
18
|
|
|
|
|
|
|
current_build_town_kana => '', |
19
|
|
|
|
|
|
|
}, $class; |
20
|
|
|
|
|
|
|
|
21
|
17
|
50
|
66
|
|
|
282
|
if ( ! $self->{fh} && $self->{file} && -f $self->{file}) { |
|
|
|
33
|
|
|
|
|
22
|
4
|
|
|
|
|
149
|
open $self->{fh}, '<:encoding(cp932)', $self->{file}; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
17
|
|
|
|
|
183
|
$self; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub fetch_obj { |
29
|
76
|
|
|
76
|
1
|
59483
|
my($self, ) = @_; |
30
|
|
|
|
|
|
|
|
31
|
76
|
|
|
|
|
288
|
my $row = $self->get_line; |
32
|
76
|
100
|
|
|
|
191
|
return unless $row; |
33
|
75
|
|
|
|
|
409
|
my @names = Parse::JapanesePostalCode::Row->columns; |
34
|
75
|
|
|
|
|
157
|
my %columns; |
35
|
75
|
|
|
|
|
98
|
@columns{@names} = @{ $row }; |
|
75
|
|
|
|
|
851
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Parse::JapanesePostalCode::Row->new( |
38
|
|
|
|
|
|
|
build_town => $self->{current_build_town}, |
39
|
|
|
|
|
|
|
build_town_kana => $self->{current_build_town_kana}, |
40
|
|
|
|
|
|
|
katakana_h2z => $self->{katakana_h2z}, |
41
|
|
|
|
|
|
|
alnum_z2h => $self->{alnum_z2h}, |
42
|
75
|
|
|
|
|
633
|
%columns, |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub _get_line { |
47
|
88
|
|
|
88
|
|
137
|
my($self, ) = @_; |
48
|
|
|
|
|
|
|
|
49
|
88
|
|
|
|
|
188
|
my $fh = $self->{fh}; |
50
|
88
|
|
|
|
|
686
|
my $line = <$fh>; |
51
|
88
|
100
|
|
|
|
250
|
return unless $line; |
52
|
86
|
|
|
|
|
651
|
$line =~ s/\r\n$//; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# easy csv parser for KEN_ALL.csv |
55
|
|
|
|
|
|
|
my @row = map { |
56
|
86
|
|
|
|
|
741
|
my $data = $_; |
|
1289
|
|
|
|
|
1532
|
|
57
|
1289
|
|
|
|
|
2542
|
$data =~ s/^"//; |
58
|
1289
|
|
|
|
|
2743
|
$data =~ s/"$//; |
59
|
1289
|
|
|
|
|
2854
|
$data; |
60
|
|
|
|
|
|
|
} split ',', $line; |
61
|
|
|
|
|
|
|
|
62
|
86
|
|
|
|
|
364
|
\@row; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub get_line { |
66
|
78
|
|
|
78
|
1
|
1425
|
my($self, ) = @_; |
67
|
|
|
|
|
|
|
|
68
|
78
|
|
|
|
|
235
|
my $row = $self->_get_line; |
69
|
78
|
100
|
|
|
|
246
|
return unless $row; |
70
|
76
|
100
|
|
|
|
593
|
if ($row->[8] =~ /(.+[^)]$/) { |
71
|
7
|
|
|
|
|
19
|
my $past_town_kana = $row->[5]; |
72
|
7
|
|
|
|
|
44
|
while (1) { |
73
|
10
|
|
|
|
|
31
|
my $tmp = $self->_get_line; |
74
|
10
|
50
|
|
|
|
33
|
return unless $tmp; |
75
|
10
|
100
|
|
|
|
45
|
$row->[5] .= $tmp->[5] unless $past_town_kana eq $tmp->[5]; |
76
|
10
|
|
|
|
|
21
|
$row->[8] .= $tmp->[8]; |
77
|
10
|
100
|
|
|
|
61
|
last if $row->[8] =~ /\)$/; |
78
|
3
|
|
|
|
|
9
|
$past_town_kana = $tmp->[5]; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
76
|
|
|
|
|
161
|
my $town = $row->[8]; |
83
|
|
|
|
|
|
|
|
84
|
76
|
100
|
66
|
|
|
676
|
if ($town =~ /^(.+)(次のビルを除く)$/) { |
|
|
100
|
|
|
|
|
|
85
|
1
|
|
|
|
|
4
|
$self->{current_build_town} = $1; |
86
|
1
|
|
|
|
|
7
|
($self->{current_build_town_kana}) = $row->[5] =~ /^(.+)\(/; |
87
|
|
|
|
|
|
|
} elsif ($row->[2] eq '4530002' && $town =~ /^名駅\(/) { |
88
|
1
|
|
|
|
|
2
|
$self->{current_build_town} = '名駅'; |
89
|
1
|
|
|
|
|
2
|
$self->{current_build_town_kana} = 'メイエキ'; |
90
|
|
|
|
|
|
|
} else { |
91
|
74
|
|
|
|
|
179
|
my $current_build_town = $self->{current_build_town}; |
92
|
74
|
100
|
|
|
|
926
|
unless ($town =~ /^$current_build_town.+(.+階.*)$/) { |
93
|
66
|
|
|
|
|
127
|
$self->{current_build_town} = ''; |
94
|
66
|
|
|
|
|
166
|
$self->{current_build_town_kana} = ''; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
76
|
|
|
|
|
174
|
$row; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
1; |
102
|
|
|
|
|
|
|
__END__ |