A Program deals the YouDaoDict's export text
I found YouDaoDict's exported text too loose to creating so many printable pages.So I determined to write a program make it more tight for me.
I know the perl language,but I'm not familiar with it.I used severl hours to read tutorials about perl.
In the final,I finished it.
There is a big problem in the program that it just deal the utf-8 encoding text.
The Following code:
#!/usr/bin/perl
#usage: input_words_file output_words_file
use strict;
use warnings;
open my $in, "<", shift or die "Cannot open words1.txt:$!";
open my $out, ">>", shift or die "Can't open words2.txt:$!";
while(<$in>){
my $linetext = $_;
$linetext =~ s/\n//g;
if( $linetext =~ /^\d+/ ){
$linetext = "\n".$linetext;
}
print $out $linetext;
}
close $in;
close $out;
posted on 2010-05-16 20:28 Hecate_Eos 阅读(148) 评论(0) 收藏 举报
浙公网安备 33010602011771号