|
|
|
Simple email validation
5
Simple function to check for a valid email address. Makes sure the @ and a . are in the right place. There is most likely a perl package on CPAN that would be more extensive, but this happens to work for my uses.




magento
comsunshine
wellskaka
aussiegadget
batteriesmall
taylargreenson
chaonidaye
publishhome
seasoom
luca
all-battery
dannyboy
tinydeal8388
jjanedan
sundaramkumar
batteryshops518
shenma
minideal
batteryerer
whiteyoung

|
|
|
---
Sasha Chorny, http://chorny.net
Also, you have the host and sub host separation parsing good, but the local name parsing allows an infinite number of periods in a row.
-CB
# Somewhat better validation
$email =~ /^[\w\+-]+(\.[\w\+-]+)*@[\w-]+(\.[\w-]+)*\.\w{2,4}$/;
# Much better validation per RFC 822 & RFC 2822
$email =~ /^[\w,!#$%&'*+\/=?^`{|}~-]+(\.[w,!#$%&'*+\/=?^`{|}~-]+)*@[\w-]+(\.[\w-]+)*\.[\w]{2,}$/;
# You could also allow for the standardized maximum lengths...