#!/usr/local/bin/perl $sender = 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=.*$sender/io; if ($type =~ /^to=/) { print "$msgid{$sel}$from{$sel}$_" if $from{$sel} ne ''; delete $msgid{$sel}; delete $from{$sel}; } }