[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Parsing rfc822 headers



On Tue, Jun 29, 1999 at 04:55:04PM +0200, Christian Borup wrote:
> I just came up with this sub that parses a rfc822 header and stuffs it
> into a array of hashes (yes - it works).
> 
> sub headers {
>   return [ map { my $q= {}; @{$q}{'key','value'}= split(/:\s+/, $_, 2);
> $q } split(/\n(?!\s)/, $_[0]) ];
> }
> 
> I can't help but to think the there must be another (shorter/more fun)
> way of dooing this. For starters, I'd really like to get rid of $q.

use Mail::Header;
$head = Mail::Header->new(\@Mail);

Are modules fun? :P

-- 

Michael G Schwern                                           schwern@pobox.com
                    http://www.pobox.com/~schwern
     /(?:(?:(1)[.-]?)?\(?(\d{3})\)?[.-]?)?(\d{3})[.-]?(\d{4})(x\d+)?/i

==== Want to unsubscribe from Fun With Perl?
==== Well, if you insist... Send mail with body "unsubscribe" to
==== fwp-request@technofile.org