鉴于(a)Perl针对文本处理进行了优化Unix-y administrative tasks; and (b) theMBOXemail storage format is both plain text and deeply rooted in Unix culture — you’d think Perl would be a terrific scripting language for mbox parsing.

但我总是不喜欢整个邮件::hierarchy of CPAN modules, several of which provide ways to parse mbox files (along with other mail storage formats)They reek of over-engineering — complicated APIs and slow performanceOne of Larry Wall’s guiding precepts for Perl is, “Easy things should be easy, and hard things should be possible.” The modules in the邮件::层次结构失败了“简单的事情应该是容易的”测试。

In response, Simon Cozens and several collaborators have spearheaded the Perl Email Project, the product of which is the relatively new电子邮件::CPAN模块的层次结构These modules are simple, fast, and easy to use我换了邮件:: MboxParser电子邮件::文件夹in a script I wrote to process mbox files full of T-shirt orders, and it ran over 10 times fasterEven better, I found the syntax more intuitive — more, well,Perl化

例如,在我的原始脚本中使用邮件:: MboxParser, given a message object$味精,得到身体$味精as a string, I needed to do this:

my $body = $msg->body($msg->find_body);
my $text = $body->as_string;

而使用电子邮件::文件夹(和电子邮件::简单), I can just write:

我的$ text = $ msg-> body;

几周前,Cozens为Perl.com写了一篇文章,“The Evolution of Perl Email Handling”, wherein he makes a compelling case for the new电子邮件::modules while providing a good introduction to their usageHighly recommended for anyone who uses Perl to read email files.