[root@dr-mysql01 ~]# cat ip.pl
use Encode;
use Encode::CN;
use JSON;
use URI::Escape;
use LWP::Simple;
print "hostip is $_
";
$host = "http://ip.taobao.com/service/getIpInfo.php?ip=$ARGV[0]";
$content = get($host);
print "$content
";
$perl_scalar = decode_json($content);
$var=$perl_scalar->{data}->{ip};
print $var
[root@dr-mysql01 ~]# perl ip.pl 202.101.172.35
hostip is
{"code":0,"data":{"country":"u4e2du56fd","country_id":"CN","area":"u534eu4e1c","area_id":"300000","region":"u6d59u6c5fu7701","region_id":"330000","city":"u676du5ddeu5e02","city_id":"330100","county":"","county_id":"-1","isp":"u7535u4fe1","isp_id":"100017","ip":"202.101.172.35"}}
202.101.172.35[root@dr-mysql01 ~]#