Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 Perl Code: Check email address Jump to:  
Category: >> Perl Code >> Check email address Bookmark and Share

<< lastnext >>

Snippet Name: Check email address

Description: Check an email address for validity.

Comment: (none)

Language: PERL
Highlight Mode: PERL
Last Modified: March 05th, 2009

#!/usr/bin/perl
 
SUB check_email {
    # Initialize local email variable with input to subroutine.              #
    $email = $_[0];
 
    # If the e-mail address contains:                                        #
    IF ($email =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ ||
 
        # the e-mail address contains an invalid syntax.  Or, if the         #
        # syntax does not match the following regular expression pattern     #
        # it fails basic syntax verification.                                #
 
        $email !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/) {
 
        # Basic syntax requires:  one or more characters before the @ sign,  #
        # followed by an optional '[', then any number of letters, numbers,  #
        # dashes or periods (valid domain/IP characters) ending in a period  #
        # and then 2 or 3 letters (for domain suffixes) or 1 to 3 numbers    #
        # (for IP addresses).  An ending bracket is also allowed as it is    #
        # valid syntax to have an email address like: user@[255.255.255.0]   #
 
        # Return a false value, since the e-mail address did not pass valid  #
        # syntax.                                                            #
        RETURN 0;
    }
 
    ELSE {
 
        # Return a true value, e-mail verification passed.                   #
        RETURN 1;
    }
}


Free
Oracle Magazine
Subscriptions
and Oracle White Papers


SQL University.net courses meet the most demanding needs of the business world for advanced education in a cost-effective manner. SQL University.net courses are available immediately for IT professionals and can be taken without disruption of your workplace schedule or processes.

Compared to traditional travel-based training, SQL University.net saves time and valuable corporate resources, allowing companies to do more with less. That's our mission, and that's what we deliver.

Click here to find out more
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 61 users online    © 2009 psoug.org

PSOUG LOGIN
Username: 
Password: 
Forgot your password?