#!/usr/bin/perl use IP::QQWry::Decoded; use Encode; use utf8; binmode(STDIN, ':encoding(utf8)'); #这三行 binmode(STDOUT, ':encoding(utf8)'); #抄别人的 binmode(STDERR, ':encoding(utf8)'); #用来输出中文,和拿中文查找 my $qqwry=IP::QQWry::Decoded->new('qqwry.dat','gbk'); open UNUSE,'iplist.txt'; while (<UNUSE>){ ($id,$ip,$key)=/(/d+)/s+(.*?)/s+(.*)/; my $info=$qqwry->query("$ip"); #其实关键代码就这一行,哈哈 printf "%s/t%s/t%s/n",$id,$ip,$key if $info=~/地区名/; }