why isn't this working (perl Question)

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Eden Li
Date:  
Subject: why isn't this working (perl Question)
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


From: "David A. Sinck" <>
> 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.