本帖最后由 523066680 于 2017-2-17 17:45 编辑
- use Encode;
- open READ, "<:encoding(gbk)", "src.txt";
- my %hash;
- for my $e ( <READ> )
- {
- $e=~s/\r?\n$//;
- if ($e=~/(\d+)\p{han}(\d+)\p{han}(\d+)\p{han}(\d+)\p{han}(\d+)\p{han}(\d+)\p{han}/)
- {
- $t = sprintf("%d%02d%02d%02d%02d%02d", $1, $2, $3, $4, $5, $6 );
- $hash{ $t } = $e;
- }
- }
- close READ;
-
- grep { print encode('gbk', $hash{$_}),"\n" } ( sort keys %hash );
复制代码 假设时间不重复~ 假设文本为GBK |