http://www.perlmonks.org?node_id=904917

vboy1997 has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,

I have a huge mail log file with each entry looking like this,

Dec 8 08:49:21 b.mx.sonic.net sm-mta18242: jB8GnCuK018242: from=<cj@oreilly.com>, size=10731, class="0", nrcpts=2, msgid=<E4461FEB-1B74-4612-80DC-3A39B04D89B1@oreilly.com>, proto=ESMTP, daemon=MTA, relay=mwest.oreilly.com 209.204.146.24
Dec 8 08:49:21 b.mx.sonic.net sm-mta18528: jB8GnCuK018242: to=<mkirk@corp.sonic.net>,<dane@corp.sonic.net>, delay=00:00:00, xdelay=00:00:00, mailer=esmtp, pri=160731, relay=lds.sonic.net. 208.201.249.231, dsn=2.0.0, stat=Sent (jB8GnLpC004736 Message accepted for delivery)

I want to split each entry into 4 parts and store them inside a HoA. The 4 parts are:

$header = everything before the $id
$id = jB8GnCuK018242
$to_from = from=<cj@oreilly.com> or to=<mkirk@corp.sonic.net>,<dane@corp.sonic.net>
$footer = everything after the $to_from section
Any help or pointers on how I can do this would be greatly appreciated. Thank you all.