| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WWW::YahooMaps; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
require 5.005_62; |
|
4
|
1
|
|
|
1
|
|
694
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
36
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
74
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require Exporter; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.3'; |
|
12
|
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
1124
|
use URI::Escape; |
|
|
1
|
|
|
|
|
1716
|
|
|
|
1
|
|
|
|
|
843
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub stringtolink { |
|
16
|
|
|
|
|
|
|
|
|
17
|
0
|
|
|
0
|
1
|
|
my ($country, $language, $string, $swap) = @_; |
|
18
|
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
$string =~ m@^([^\;\n]+)[\;\n]+([^\;\n]+)@s; |
|
20
|
0
|
|
|
|
|
|
my ($street, $city) = ($1, $2); |
|
21
|
|
|
|
|
|
|
|
|
22
|
0
|
0
|
|
|
|
|
if ($swap) { |
|
23
|
0
|
|
|
|
|
|
($street, $city) = ($city, $street); |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
my %addr = ( |
|
27
|
|
|
|
|
|
|
"street" => $street, |
|
28
|
|
|
|
|
|
|
"city" => $city, |
|
29
|
|
|
|
|
|
|
"country" => $country, |
|
30
|
|
|
|
|
|
|
"language" => "us", |
|
31
|
|
|
|
|
|
|
); |
|
32
|
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
my $url = hashreftolink(\%addr); |
|
34
|
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
return $url; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub hashreftolink { |
|
39
|
0
|
|
|
0
|
1
|
|
my ($rh_addr) = @_; |
|
40
|
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
$rh_addr->{language} = "us"; |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
#test if the language we want exists, whether we have given at least a country and a city |
|
44
|
0
|
0
|
0
|
|
|
|
if (&testlang($rh_addr->{language}) && |
|
|
|
|
0
|
|
|
|
|
|
45
|
|
|
|
|
|
|
&testcountry($rh_addr->{country}) && |
|
46
|
|
|
|
|
|
|
&cleanstring($rh_addr->{city})) { |
|
47
|
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
$rh_addr->{language} = &ukcheck($rh_addr->{language}); |
|
49
|
0
|
|
|
|
|
|
$rh_addr->{country} = &ukcheck($rh_addr->{country}); |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
#special treatment for canada and US |
|
52
|
0
|
0
|
|
|
|
|
if ($rh_addr->{country} eq "ca") { |
|
|
|
0
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
$rh_addr->{language} = "ca"; |
|
54
|
|
|
|
|
|
|
} elsif ($rh_addr->{country} eq "us") { |
|
55
|
0
|
|
|
|
|
|
$rh_addr->{language} = "us"; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
#take care of US dot-related issues |
|
59
|
0
|
|
|
|
|
|
my $langdot = ''; |
|
60
|
|
|
|
|
|
|
|
|
61
|
0
|
0
|
|
|
|
|
if ($rh_addr->{language} eq "us") { |
|
62
|
0
|
|
|
|
|
|
$rh_addr->{language} = ""; |
|
63
|
|
|
|
|
|
|
} else { |
|
64
|
0
|
|
|
|
|
|
$langdot = '.'; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
my $url = ""; |
|
68
|
0
|
|
|
|
|
|
$url = "http://" . $rh_addr->{language} . $langdot . "maps.yahoo.com"; |
|
69
|
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
$url .= "/py"; |
|
71
|
|
|
|
|
|
|
|
|
72
|
0
|
0
|
|
|
|
|
if ($rh_addr->{country} ne "ca") { |
|
73
|
0
|
|
|
|
|
|
$url .= "/lg:" . $rh_addr->{language}; |
|
74
|
0
|
|
|
|
|
|
$url .= "/lc:" . $rh_addr->{language}; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
$url .= "/maps_result?BFCat=&Pyt=Tmap&newFL="; |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# street |
|
80
|
0
|
0
|
|
|
|
|
if ($rh_addr->{street}){ |
|
81
|
0
|
|
|
|
|
|
my $street = cleanstring($rh_addr->{street}); |
|
82
|
0
|
|
|
|
|
|
$street = uri_escape($street); |
|
83
|
0
|
|
|
|
|
|
$url .= "&addr=" . $street; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# city |
|
87
|
0
|
|
|
|
|
|
my $city = cleanstring($rh_addr->{city}); |
|
88
|
0
|
|
|
|
|
|
$city = uri_escape($city); |
|
89
|
0
|
|
|
|
|
|
$url .= "&csz=" . $city; |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# country |
|
92
|
0
|
|
|
|
|
|
$url .= "&country=" . $rh_addr->{country}; |
|
93
|
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
return $url; |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
} else { |
|
97
|
0
|
|
|
|
|
|
return 0; |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub ukcheck { |
|
103
|
|
|
|
|
|
|
# needed because "uk" is not a ISO 3166 code |
|
104
|
|
|
|
|
|
|
# "gb" is the code, but Yahoo! uses uk |
|
105
|
|
|
|
|
|
|
|
|
106
|
0
|
|
|
0
|
0
|
|
my ($string) = @_; |
|
107
|
0
|
0
|
|
|
|
|
if ($string eq "gb"){ |
|
108
|
0
|
|
|
|
|
|
return "uk"; |
|
109
|
|
|
|
|
|
|
} else { |
|
110
|
0
|
|
|
|
|
|
return $string; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub testlang { |
|
115
|
|
|
|
|
|
|
|
|
116
|
0
|
|
|
0
|
1
|
|
my ($lang) = @_; |
|
117
|
|
|
|
|
|
|
|
|
118
|
0
|
0
|
|
|
|
|
if ($lang){ |
|
119
|
|
|
|
|
|
|
# list of languages in which Yahoo offers maps |
|
120
|
0
|
|
|
|
|
|
my %langs = ( |
|
121
|
|
|
|
|
|
|
"us" => 1, |
|
122
|
|
|
|
|
|
|
); |
|
123
|
0
|
0
|
|
|
|
|
return $langs{$lang} ? 1 : 0 ; |
|
124
|
|
|
|
|
|
|
} else { |
|
125
|
0
|
|
|
|
|
|
return 0; |
|
126
|
|
|
|
|
|
|
} |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub testcountry { |
|
130
|
0
|
|
|
0
|
1
|
|
my ($cty) = @_; |
|
131
|
|
|
|
|
|
|
|
|
132
|
0
|
0
|
|
|
|
|
if ($cty){ |
|
133
|
|
|
|
|
|
|
# list of countries for which Yahoo has maps |
|
134
|
0
|
|
|
|
|
|
my %ctys = ( |
|
135
|
|
|
|
|
|
|
"ca" => 1, |
|
136
|
|
|
|
|
|
|
"us" => 1, |
|
137
|
|
|
|
|
|
|
); |
|
138
|
0
|
0
|
|
|
|
|
return $ctys{$cty} ? 1 : 0 ; |
|
139
|
|
|
|
|
|
|
} else { |
|
140
|
0
|
|
|
|
|
|
return 0; |
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
} |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub cleanstring { |
|
145
|
|
|
|
|
|
|
#remove unecessary whitespace |
|
146
|
0
|
|
|
0
|
0
|
|
my ($string) = @_; |
|
147
|
0
|
|
|
|
|
|
$string =~ s@\n@ @g; |
|
148
|
0
|
|
|
|
|
|
$string =~ s@^\s+@@g; |
|
149
|
0
|
|
|
|
|
|
$string =~ s@\s+$@@g; |
|
150
|
0
|
|
|
|
|
|
return $string; |
|
151
|
|
|
|
|
|
|
} |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
1; |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
__END__ |