why isn't this working (perl Question)

Eden Li plug-discuss@lists.PLUG.phoenix.az.us
Sun, 22 Apr 2001 21:38:12 -0700


Actually this fails on quite a few cases, including my valid email
address...
The rule of thumb for email addresses is, there is no way to validate syntax
of an email address unless you send to and and get a reply back from a
_real live person_. If you're trying slurp up things between <>'s that
happen
to have a @ in the middle, you'd probably want to do this:

$text = ($bufr =~ /<([^>]*@[^>]*)>/);
if (defined $text and $text ne "")
{
    # do something with $text here..
}

This may or may not slurp up all the emails in a log file (unless the log
file is well-formed and is guaranteed to have emails between <> in
all cases).

Anyway, a good reference for more info about regular expressions and
stuff can be found in ``perldoc perlre''.

HTH,
Eden
eden.li@asu.edu

From: "David A. Sinck" <sinck@ugive.com>
> Try instead:
>
> if ($bufr =~ /<\w+@\w+\.\w+>/)
> {
> $email = $1;
> # other logic for having detected valid email here
> }
>
> Notice the the regex is closer to enforcing a valid email, but still
> does not guarantee it.  For instance, it ignores local deliveries as
> valid (sinck) and probably some other cases.