Re: Perl scripts: line by line parsing vs accumulating (was: the correct way to read a big directory? Mutt?)
On 2015-05-25 03:22:36 +0200, Vincent Lefevre wrote:
> One can do better. The code I used in the second test was:
>
> $header =~ /^\S+:/ || $header =~ /^From / or die;
> $header =~ /\n[^:\s]+\s/ and die;
> $header =~ /^Message-ID:.*^Message-ID:/ims and die;
> $header =~ /^Message-ID:\s+(<\S+>)( \(added by .*\))?$/im or die;
>
> where $header is the full header.
In this test, the second line should actually be changed to:
$header =~ /\n(:|[^:\s]+\s)/ and die;
Otherwise one misses to detect some broken headers.
--
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
Reply to: