#!/usr/local/bin/perl $recip = shift(@ARGV); while (<>) { @words = split(' ', $_, 7); $sel = $words[3] . $words[5]; $type = $words[6]; $msgid{$sel} = $_ if $type =~ /^message-id=/; $from{$sel} = $_ if $type =~ /^from=/; if ($type =~ /^to=/) { print "$msgid{$sel}$from{$sel}$_" if $type =~ /$recip/io; delete $msgid{$sel}; delete $from{$sel}; } }