我正在尝试修改现有的 perl 脚本以支持地理编码。为它找到了这个模块:http ://metacpan.org/pod/Geo::Coder::Google
我只是不知道如何从它返回的哈希结构中提取数据(我不是 perl 编码器,这只是我必须修复的一些遗留脚本)。
{
'AddressDetails' => {
'Country' => {
'AdministrativeArea' => {
'SubAdministrativeArea' => {
'SubAdministrativeAreaName' => 'San Francisco',
'Locality' => {
'PostalCode' => {
'PostalCodeNumber' => '94107'
},
'LocalityName' => 'San Francisco',
'Thoroughfare' => {
'ThoroughfareName' => '548 4th St'
}
}
},
'AdministrativeAreaName' => 'CA'
},
'CountryNameCode' => 'US'
}
},
'address' => '548 4th St, San Francisco, CA 94107, USA',
'Point' => {
'coordinates' => [
'-122.397323',
'37.778993',
0
]
}
}
尝试了我在谷歌上找到的所有哈希教程,我能打印的最多的是像 HASH(0x91e5558) 这样的东西。到目前为止,我的代码是以模块显示的为例:
use Geo::Coder::Google;
my $geocoder = Geo::Coder::Google->new(apikey => 'Your API Key');
my $location = $geocoder->geocode( location => 'Hollywood and Highland, Los Angeles, CA');
我只想要 Point -> 将数据坐标到它自己的变量中,然后我可以将其写入数据库。