用Perl查找包含非中文字符的记录
Ricky
posted @ 2015年7月28日 09:04
in Other
, 1039 阅读
#!/usr/bin/perl #Author: #Version: 0.1 #Description: find all non chs chars #Usage: use Getopt::Std; Getopt::Std::getopts('f:', \%options); $cifaFile=$options{f}; $nonChsFile="result.$cifaFile"; no warnings qw(uninitialized); use open ":encoding(utf8)",":std"; open(cifa,"$cifaFile") || die "can't open"; open(nonChs,">$nonChsFile") || die "can't open"; while(<cifa>){ $line=$_; #split with seperator @array = split(/\|ine,3); if ($array[1] ne "0" and $array[2]!~/^[\x{4E00}-\x{9FA5}]+$/){ #write search result if found print nonChs $line; } } close(cifa); close(nonChs);