in reply to Arrays - Getting a single column from more than one row
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
|
|---|