Christopher Lyon wrote:
>
> From: simran [mailto:[EMAIL PROTECTED]
> >
> > On Tue, 2003-10-14 at 13:59, Christopher Lyon wrote:
> >
> > > I have a line of text that I want to pull an e-mail address
> > > out from. Is this the best way to pull that information from
> > > that line?
> > >
> > > <snip>
> > > $user = 'From: "First Last Name" <[EMAIL PROTECTED]>';
> > >
> > > @addy = split(/</, $user, 2);
> > > chop $addy[1];
> > > </snip>
> > >
> > >
> > > Also, how do you handle if the email is in brackets like so?
> > >
> > > $user = 'From: "First Last Name" [EMAIL PROTECTED]';
> > >
> >
> > the cpan module:
> >
> > http://search.cpan.org/~miyagawa/Email-Find-0.09/lib/Email/Find.pm
> >
> > might come in handy...
>
> I have given that a try and it doesn't work all that great. It
> seems to be more suited for the To or CC fields and not the from.

What's your problem Christopher? It works fine with the data you've
shown. See below.

Cheers,

Rob



use strict;
use warnings;

use Email::Find;

my $user = 'From: "First Last Name" <[EMAIL PROTECTED]>';

foreach my $user (
    'From: "First Last Name" <[EMAIL PROTECTED]>',
    'From: "First Last Name" [EMAIL PROTECTED]' ) {

  find_emails ($user, sub {
    my $email = pop @_;
    print $email, "\n";
    $email;
  });
}

** OUTPUT **

[EMAIL PROTECTED]
[EMAIL PROTECTED]



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to