#!/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"); #其實(shí)關(guān)鍵代碼就這一行,哈哈 printf "%s/t%s/t%s/n",$id,$ip,$key if $info=~/地區(qū)名/; }