in reply to grabbing certain lines

I still think that using a regex to break the data up into the two parts you want,
and catching them in a hash, is the easiest way to achieve what you are asking for.

Orig regex beefed up slightly.

#!/usr/local/bin/perl -w use strict; use Data::Dumper; my %names_emails = map { /^(?:To|From|Reply-To): (\S+)\s+<?([^\s>]+)/ +} <DATA>; print Dumper( \%names_emails ); __DATA__ To: Bob <test@spam.com> From: lucy test@wherever.c0m Reply-To: somebody somebody@spam.com To: Bob2 <test2@spam.com>

Output:
:!./test.pl $VAR1 = { 'somebody' => 'somebody@spam.com', 'lucy' => 'test@wherever.c0m', 'Bob2' => 'test2@spam.com', 'Bob' => 'test@spam.com' };

Disagree? Am I missing what you are looking for?