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?

In reply to Re: grabbing certain lines by Wonko the sane
in thread grabbing certain lines by imlou

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.