Perl - 日期时间排序

There's more than one way to do it!
https://metacpan.org http://perlmonks.org
回复
头像
523066680
Administrator
Administrator
帖子: 573
注册时间: 2016年07月19日 12:14
联系:

Perl - 日期时间排序

帖子 523066680 »

原问题 http://bbs.bathome.net/thread-43203-1-1.html
use Encode;
use IO::Handle;
STDOUT->autoflush(1);

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 );
回复

在线用户

正浏览此版面之用户: 没有注册用户 和 0 访客