Created
October 24, 2012 13:27
-
-
Save terrencehan/3946050 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#你在使用这个代码之前先要把输入文件转换成UTF-8的编码 | |
open $in, "<", "a.txt"; | |
while (<$in>) { | |
chomp; | |
( $city, $pinyin ) = split; | |
$city .= "市"; | |
$hash{$city} = $pinyin; | |
} | |
$citys = join "|", keys %hash; | |
open $in, "<", "IPData.txt"; | |
open $out, ">", "out.txt"; | |
while (<$in>) { | |
s/($citys)/$hash{$&}/g; | |
print $out $_; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment