line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Parse::JapanesePostalCode; |
2
|
15
|
|
|
15
|
|
505550
|
use strict; |
|
15
|
|
|
|
|
39
|
|
|
15
|
|
|
|
|
465
|
|
3
|
15
|
|
|
15
|
|
72
|
use warnings; |
|
15
|
|
|
|
|
30
|
|
|
15
|
|
|
|
|
337
|
|
4
|
15
|
|
|
15
|
|
1039
|
use utf8; |
|
15
|
|
|
|
|
39
|
|
|
15
|
|
|
|
|
109
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
6
|
|
|
|
|
|
|
|
7
|
15
|
|
|
15
|
|
10387
|
use Parse::JapanesePostalCode::Row; |
|
15
|
|
|
|
|
45
|
|
|
15
|
|
|
|
|
11104
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
16
|
|
|
16
|
1
|
75784
|
my($class, %opts) = @_; |
11
|
|
|
|
|
|
|
|
12
|
16
|
|
|
|
|
202
|
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
|
16
|
50
|
66
|
|
|
458
|
if ( ! $self->{fh} && $self->{file} && -f $self->{file}) { |
|
|
|
66
|
|
|
|
|
22
|
4
|
|
|
|
|
206
|
open $self->{fh}, '<:encoding(cp932)', $self->{file}; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
16
|
|
|
|
|
214
|
$self; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub fetch_obj { |
29
|
75
|
|
|
75
|
1
|
64329
|
my($self, ) = @_; |
30
|
|
|
|
|
|
|
|
31
|
75
|
|
|
|
|
256
|
my $row = $self->get_line; |
32
|
75
|
100
|
|
|
|
179
|
return unless $row; |
33
|
74
|
|
|
|
|
426
|
my @names = Parse::JapanesePostalCode::Row->columns; |
34
|
74
|
|
|
|
|
145
|
my %columns; |
35
|
74
|
|
|
|
|
102
|
@columns{@names} = @{ $row }; |
|
74
|
|
|
|
|
927
|
|
36
|
|
|
|
|
|
|
|
37
|
74
|
|
|
|
|
657
|
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
|
|
|
|
|
|
|
%columns, |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub _get_line { |
47
|
85
|
|
|
85
|
|
120
|
my($self, ) = @_; |
48
|
|
|
|
|
|
|
|
49
|
85
|
|
|
|
|
181
|
my $fh = $self->{fh}; |
50
|
85
|
|
|
|
|
877
|
my $line = <$fh>; |
51
|
85
|
100
|
|
|
|
288
|
return unless $line; |
52
|
83
|
|
|
|
|
652
|
$line =~ s/\r\n$//; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# easy csv parser for KEN_ALL.csv |
55
|
1244
|
|
|
|
|
1317
|
my @row = map { |
56
|
83
|
|
|
|
|
844
|
my $data = $_; |
57
|
1244
|
|
|
|
|
2404
|
$data =~ s/^"//; |
58
|
1244
|
|
|
|
|
2588
|
$data =~ s/"$//; |
59
|
1244
|
|
|
|
|
2301
|
$data; |
60
|
|
|
|
|
|
|
} split ',', $line; |
61
|
|
|
|
|
|
|
|
62
|
83
|
|
|
|
|
378
|
\@row; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub get_line { |
66
|
77
|
|
|
77
|
1
|
1207
|
my($self, ) = @_; |
67
|
|
|
|
|
|
|
|
68
|
77
|
|
|
|
|
228
|
my $row = $self->_get_line; |
69
|
77
|
100
|
|
|
|
215
|
return unless $row; |
70
|
75
|
100
|
|
|
|
584
|
if ($row->[8] =~ /(.+[^)]$/) { |
71
|
6
|
|
|
|
|
11
|
while (1) { |
72
|
8
|
|
|
|
|
35
|
my $tmp = $self->_get_line; |
73
|
8
|
50
|
|
|
|
21
|
return unless $tmp; |
74
|
8
|
|
|
|
|
20
|
$row->[5] .= $tmp->[5]; |
75
|
8
|
|
|
|
|
23
|
$row->[8] .= $tmp->[8]; |
76
|
8
|
100
|
|
|
|
51
|
last if $row->[8] =~ /\)$/; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
75
|
|
|
|
|
195
|
my $town = $row->[8]; |
81
|
|
|
|
|
|
|
|
82
|
75
|
100
|
66
|
|
|
685
|
if ($town =~ /^(.+)(次のビルを除く)$/) { |
|
|
100
|
|
|
|
|
|
83
|
1
|
|
|
|
|
5
|
$self->{current_build_town} = $1; |
84
|
1
|
|
|
|
|
8
|
($self->{current_build_town_kana}) = $row->[5] =~ /^(.+)\(/; |
85
|
|
|
|
|
|
|
} elsif ($row->[2] eq '4530002' && $town =~ /^名駅\(/) { |
86
|
1
|
|
|
|
|
4
|
$self->{current_build_town} = '名駅'; |
87
|
1
|
|
|
|
|
3
|
$self->{current_build_town_kana} = 'メイエキ'; |
88
|
|
|
|
|
|
|
} else { |
89
|
73
|
|
|
|
|
309
|
my $current_build_town = $self->{current_build_town}; |
90
|
73
|
100
|
|
|
|
1020
|
unless ($town =~ /^$current_build_town.+(.+階.*)$/) { |
91
|
65
|
|
|
|
|
123
|
$self->{current_build_town} = ''; |
92
|
65
|
|
|
|
|
152
|
$self->{current_build_town_kana} = ''; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
75
|
|
|
|
|
164
|
$row; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
1; |
100
|
|
|
|
|
|
|
__END__ |