Is @emails a list of lists, or is it a list of strings with some sort of delimiter between fields?

Assuming it's a list of lists:

foreach my $record ( @emails ) { my $email_address = $record->[1]; # now do something with your email address. }

Or maybe it's a list of strings with space-delimited fields (that's problematic):

foreach my $record ( @emails ) { if( $record =~ m/\S+\s+(\S+)/ ) { my $email_address = $1; # Do something with $email_address } else { die "Bad record format.\n"; }

That assumes that the name field contains only a single name, and that there are no spaces in the address field. Maybe it's more like this:

$record =~ m/(\S+\@\S+)$/

....which would ignore the first field, and simply look for the final field, which should contain no whitespace, and should include an '@'.

Email addresses are pretty hard to match accurately, but if your data set is fairly clean this should do the trick.

If you're using this to harvest email addresses for spamming, shame on you. But I'll give you the benefit of the doubt.


Dave


In reply to Re: Arrays - Getting a single column from more than one row by davido
in thread Arrays - Getting a single column from more than one row by barrycarlyon

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.