May 2 07:06:20 lon.mail.net exim[1234]: 2012-05-02 07:06:20 1PSPtU-0004en-1e <= it_ndt_bounces@new.itunes.com H=smtpmail.com [21.5.10.4] I=[8.4.14.4]:25 P=esmtp S=1966 id=1603882764.112965659.1335927964793.Mail.cboxp@ednabay.apple.com T="New on iTunes: One Thing And, Then Another, Cooking Apps,\n Great Deals on First Seasons, and M" May 2 07:06:20 lon.mail.net exim[1234]: 2012-05-02 07:06:20 1PSPtU-0004en-1e <= it_ndt_bounces@new.itunes.com H=smtpmail.com [21.5.10.4] I=[8.4.14.4]:25 P=esmtp S=1966 id=1603882764.112965659.1335927964793.Mail.cboxp@ednabay.apple.com T="New on iTunes: One Thing And, Then Another, Cooking Apps,\n Great Deals on First Seasons, and M" May 2 07:06:20 lon.mail.net exim[1235]: 2012-05-02 07:06:20 1PSPtU-0004en-1e => peterpiper R=local_mail T=local_maildir_mail_drop #### #!/usr/bin/perl use strict; use warnings; no warnings q{uninitialized}; while (my $line = ) { chomp($line); my ( $mon, $day, $time, $loghost, $prog, $remainder ) = split m{:?\s+}, $line, 6; my %monthNos = do { my $no = 0; map { $_ => ++ $no } qw{ Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec }; }; my ( $user ) = $remainder =~ m{user=([^,]+)}; my ( $rip ) = $remainder =~ m{rip=([^,]+)}; $remainder =~ tr/"/'/; my $yr = q{2012}; my $csv = sprintf q{%02d/%02d/%s %s,%s,%s,"%s",%s,%s}, $day, $monthNos{ $mon }, $yr, $time, $loghost, $prog, $remainder, $user, $rip; print "$csv\n"; } #### if contains <= then ...... else if contains => then ..... else if contains == then .... else if contains ** then .... else somethingelse etc