line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::NHKProgram::API::Area; |
2
|
2
|
|
|
2
|
|
15923
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
62
|
|
3
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
43
|
|
4
|
2
|
|
|
2
|
|
1983
|
use utf8; |
|
2
|
|
|
|
|
20
|
|
|
2
|
|
|
|
|
10
|
|
5
|
2
|
|
|
2
|
|
58
|
use Carp; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
166
|
|
6
|
2
|
|
|
2
|
|
916
|
use Encode qw/encode_utf8 decode_utf8/; |
|
2
|
|
|
|
|
11982
|
|
|
2
|
|
|
|
|
130
|
|
7
|
2
|
|
|
2
|
|
1550
|
use parent qw/Exporter/; |
|
2
|
|
|
|
|
541
|
|
|
2
|
|
|
|
|
11
|
|
8
|
|
|
|
|
|
|
our @EXPORT_OK = qw/fetch_area_id/; |
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
|
|
535
|
use constant AREAS => { |
11
|
|
|
|
|
|
|
'010' => '札幌', |
12
|
|
|
|
|
|
|
'011' => '函館', |
13
|
|
|
|
|
|
|
'012' => '旭川', |
14
|
|
|
|
|
|
|
'013' => '帯広', |
15
|
|
|
|
|
|
|
'014' => '釧路', |
16
|
|
|
|
|
|
|
'015' => '北見', |
17
|
|
|
|
|
|
|
'016' => '室蘭', |
18
|
|
|
|
|
|
|
'020' => '青森', |
19
|
|
|
|
|
|
|
'030' => '盛岡', |
20
|
|
|
|
|
|
|
'040' => '仙台', |
21
|
|
|
|
|
|
|
'050' => '秋田', |
22
|
|
|
|
|
|
|
'060' => '山形', |
23
|
|
|
|
|
|
|
'070' => '福島', |
24
|
|
|
|
|
|
|
'080' => '水戸', |
25
|
|
|
|
|
|
|
'090' => '宇都宮', |
26
|
|
|
|
|
|
|
'100' => '前橋', |
27
|
|
|
|
|
|
|
'110' => 'さいたま', |
28
|
|
|
|
|
|
|
'120' => '千葉', |
29
|
|
|
|
|
|
|
'130' => '東京', |
30
|
|
|
|
|
|
|
'140' => '横浜', |
31
|
|
|
|
|
|
|
'150' => '新潟', |
32
|
|
|
|
|
|
|
'160' => '富山', |
33
|
|
|
|
|
|
|
'170' => '金沢', |
34
|
|
|
|
|
|
|
'180' => '福井', |
35
|
|
|
|
|
|
|
'190' => '甲府', |
36
|
|
|
|
|
|
|
'200' => '長野', |
37
|
|
|
|
|
|
|
'210' => '岐阜', |
38
|
|
|
|
|
|
|
'220' => '静岡', |
39
|
|
|
|
|
|
|
'230' => '名古屋', |
40
|
|
|
|
|
|
|
'240' => '津', |
41
|
|
|
|
|
|
|
'250' => '大津', |
42
|
|
|
|
|
|
|
'260' => '京都', |
43
|
|
|
|
|
|
|
'270' => '大阪', |
44
|
|
|
|
|
|
|
'280' => '神戸', |
45
|
|
|
|
|
|
|
'290' => '奈良', |
46
|
|
|
|
|
|
|
'300' => '和歌山', |
47
|
|
|
|
|
|
|
'310' => '鳥取', |
48
|
|
|
|
|
|
|
'320' => '松江', |
49
|
|
|
|
|
|
|
'330' => '岡山', |
50
|
|
|
|
|
|
|
'340' => '広島', |
51
|
|
|
|
|
|
|
'350' => '山口', |
52
|
|
|
|
|
|
|
'360' => '徳島', |
53
|
|
|
|
|
|
|
'370' => '高松', |
54
|
|
|
|
|
|
|
'380' => '松山', |
55
|
|
|
|
|
|
|
'390' => '高知', |
56
|
|
|
|
|
|
|
'400' => '福岡', |
57
|
|
|
|
|
|
|
'401' => '北九州', |
58
|
|
|
|
|
|
|
'410' => '佐賀', |
59
|
|
|
|
|
|
|
'420' => '長崎', |
60
|
|
|
|
|
|
|
'430' => '熊本', |
61
|
|
|
|
|
|
|
'440' => '大分', |
62
|
|
|
|
|
|
|
'450' => '宮崎', |
63
|
|
|
|
|
|
|
'460' => '鹿児島', |
64
|
|
|
|
|
|
|
'470' => '沖縄', |
65
|
2
|
|
|
2
|
|
417
|
}; |
|
2
|
|
|
|
|
8
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub fetch_area_id { |
68
|
5
|
|
|
5
|
0
|
2918
|
my $arg = shift; |
69
|
|
|
|
|
|
|
|
70
|
5
|
100
|
|
|
|
27
|
if ($arg =~ /\A\d{3}\Z/) { |
71
|
2
|
|
|
|
|
8
|
return $arg; |
72
|
|
|
|
|
|
|
} |
73
|
3
|
|
|
|
|
8
|
return _retrieve_id_by_name($arg); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub _retrieve_id_by_name { |
77
|
3
|
|
|
3
|
|
4
|
my $name = shift; |
78
|
|
|
|
|
|
|
|
79
|
3
|
|
|
|
|
5
|
eval { $name = decode_utf8($name) }; |
|
3
|
|
|
|
|
9
|
|
80
|
3
|
|
|
|
|
56
|
for my $key (keys %{+AREAS}) { |
|
3
|
|
|
|
|
35
|
|
81
|
140
|
100
|
|
|
|
281
|
return $key if AREAS->{$key} eq $name; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
1
|
|
|
|
|
9
|
croak encode_utf8("No such city: $name"); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |
88
|
|
|
|
|
|
|
|