pm link : search.cpan.org/~fayland/Lingua-Han-PinYin-0.15/lib/Lingua/Han/PinYin.pm
- #!/usr/bin/perl -w
- use Lingua::Han::PinYin();
- sub getpinyin{
- my @value = @_;
- my $pinyin = '';
- for my $out (0 .. $#value){
- $pinyin .= $value[$out];
- }
- print "$pinyin";
- }
- open(FH,$ARGV[0]) or die "Can't find filename:$!";
- while(<FH>)
- {
- next if /^#/;
- my($filmname,$size) = split /\s+/;
- my $h2p = new Lingua::Han::PinYin();
- my @value = $h2p->han2pinyin("$filmname");
- getpinyin(@value);
- print "\t$size\n";
- }
- close FH;
han2pinyin()只处理中文字符;出现其他的符号如./字符/<<>>等原样输出;
- 列表文件:
- #name size/MB
- 叶问.mp4 578M
- 夺金.mp4 644M
- 遮天.txt 6M
- 龙门飞甲.ts 1.4G
- 处理:
- [root@cz perl]# perl pinyin.pl liebiao.txt
- xiewen.mp4 578M
- duojin.mp4 644M
- zhetian.txt 6M
- longmenfeijia.ts 1.4G
貌似这里的xiewen让人有点抓狂;
错误提交给作者后,给出了新版连接地址:http://fayland.org/CPAN/Lingua-Han-PinYin-0.16.tar.gz (更新了.dat文件里的信息库)