Perl 101: Things Every Perl Programmer Should Know.

Email Addressing, Processing, and Handling

How do I see if an email address is valid?

In general, you can't. There are several methods available to see if it looks reasonable, but there is no way to determine if an address is actually deliverable without actually attempting delivery.

Using regular expressions:

    # Match basically blah@blah.blah
    if ( $addr =~ /^\S+\@\S+\.\S+$/ ) {
        print "Looks OK";

If you're doing any real work, you may wish to look to one of the modules available on, such as:


Email::Valid makes it easy to determine if an email address is well-formed:

    use Email::Valid;

    print ( Email::Valid->address( '' ) ? 'Yes' : 'No' ); # prints Yes
    print ( Email::Valid->address( '' ) ? 'Yes' : 'No' ); # prints No

Email::Valid can also tell you why an address is invalid:

    print "Invalid address: $Email::Valid::Details \n"
        unless Email::Valid->address( '' );

Want to contribute?

Submit a PR to

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.