cgi perl script command

Hello,

I have a cgi perl script that mistakenly does not accept a user email address if there is a dot symbol anywhere before the @ sign.

here is the relevant line of code

$message .= 'Invalid address<br>' if $email !~ /^[A-Za-z0-9_]+@\w{1,63}\.[a-zA-Z]{2,6}(\.[a-zA-Z]{2,6}){0,2}$/;

Open in new window


Please tell me how to remove the dot restriction.
netplus21Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jim RiddlesPrepress/OMS SpecialistCommented:
Should be as simple as the following:
$message .= 'Invalid address<br>' if $email !~ /^[A-Za-z0-9_\.]+@\w{1,63}\.[a-zA-Z]{2,6}(\.[a-zA-Z]{2,6}){0,2}$/;

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ozoCommented:
\ is not necessary before . in [], but that also incorrectly rejects any of \W before @

see
perldoc -q "How do I check a valid mail address?"

(as per  RFC822,
The Fred and Barney Comedy Team <fred&barney@stonehenge.com>
is a valid email address)
0
Jim RiddlesPrepress/OMS SpecialistCommented:
If you go by the RFC, you may be surprised by what is a valid email address...I wouldn't recommend it.  Most email providers apply more restrictions that what the RFC permits.  See the following article for more information on that subject:
I Knew How To Validate An Email Address Until I Read The RFC
0
FishMongerCommented:
Rather than hand rolling your own regex, IMO it would be better to use a module such as:
Email::Valid - Check validity of Internet email addresses
1
netplus21Author Commented:
Thank you all for your answers/suggestions.

@ozo

\ is not necessary before . in [], but that also incorrectly rejects any of \W before @

I would guess that 63 refers to the number of characters permitted. I don't understand what might be rejected incorrectly if I omit the '\'.
Shall I keep the '\' even though it's unnecessary?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
CGI

From novice to tech pro — start learning today.