我想知道如何修改下面的代码去除多行尾部的=20
个字符,主要是按照时间顺序从最初接收到的或发送到最后的时间对消息进行排序。我不确定这是否是一个内部的Perl例程。如何按日期排序mbox文件?
#!/usr/bin/perl
use warnings;
use strict;
use Mail::Box::Manager;
my $file = shift || $ENV{MAIL};
my $mgr = Mail::Box::Manager->new(
access => 'r',
);
my $folder = $mgr->open(folder => $file)
or die "$file: Unable to open: $!\n";
for my $msg ($folder->messages)
{
my $to = join(', ', map { $_->format } $msg->to);
my $from = join(', ', map { $_->format } $msg->from);
my $date = localtime($msg->timestamp);
my $subject = $msg->subject;
my $body = $msg->body;
# Strip all quoted text
$body =~ s/^>.*$//msg;
print <<"";
From: $from
To: $to
Date: $date
$body
}
当试图运行此我得到以下错误:
在同一范围内“我的”变量$味精口罩早些时候的声明在x.pl线在x.pl 15行16 语法错误,“near”))“ 语法错误在x.pl行31附近,”}“ (可能是失控的多行< <字符串从第25行开始) 由于编译错误导致执行x.pl中止。
我不确定为什么,因为语法看起来不错。
重复http://stackoverflow.com/questions/368003/how-can-i-reorder-an-mbox-file-chronologically – Bombe 2008-12-15 13:03:10
的不,这是Perl的,更具体的 – 2008-12-15 13:03:42