Simple email validation





5
Date Submitted Thu. Aug. 31st, 2006 7:58 AM
Revision 1 of 1
Scripter ctiggerf
Tags Email | Perl | RegExp | Validate
Comments 3 comments
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.

sub validate_email {
  my ($email)=@_;

  if($email =~ m/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/s) {
    return 1
  } else {
    return 0;   
  }     
}
 

Chris Falzone

www.eadexchange.com

Comments

Comments Oops
Tue. Sep. 5th, 2006 10:48 PM    Helper mceppi
Comments Isn't valid
Wed. Oct. 18th, 2006 2:31 PM    Beginner snevine
Comments e-mail validation
Mon. Feb. 11th, 2008 6:13 PM    Beginner chorny

Voting