[Perl]日本語抽出
resxファイルとかから日本語文言を抽出するためにPerlを検討してみた。
ActivePerl 5.10 使用。
もう少し改良する必要があるけど、ある程度取れているのではないかと思う。
use strict;
use utf8;
open IN, "<:encoding(utf8)", "Form1.resx";
open OUT, ">:encoding(utf8)", "Form1out.resx";
while(<IN>)
{
my $match;
if(/<value>(.*)<\/value>/)
{
$match = ${1},"\n";
}
print ;
if($match =~ /\p{Hiragana}+/)
{
print OUT $_;
}
elsif($match =~ /\p{Katakana}+/)
{
print OUT $_;
}
#elsif($match =~ /\p{Punctuation}+/)
#{
# print OUT $_;
#}
elsif($match =~ /\p{Han}+/)
{
print OUT $_;
}
}
close OUT;
close IN;