my %name2email; while () { next unless m/^(?:To|From|Reply-To): (\S+)\s+]+)/; $name2email{$1} = $2; };