CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
can any one tell how to validate correct email address using perl script

 



aniket
New User

Dec 10, 2009, 6:17 AM

Post #1 of 3 (4333 views)
can any one tell how to validate correct email address using perl script Can't Post

Can any one tell how to Write a program in perl with the following aim:

- takes an email address as input

- outputs a "valid" or "invalid" - valid if the email address is

valid, and invalid if it is invalid.

- make your own assumptions about what is a valid email addres and what is invalid.

I tried below stuff but didnt worked..please help me:

#!/usr/bin/perl -w

print ("Please type yor email id:\n");

$email = <STDIN>;

if ($email =~ /^(\w\-\_\.)+\@((\w\-\_)+\.)+[a-zA-Z]{2,}$/)

{

print ("$email is valid");

}

else {

print ("$email is invalid");

}





Please help me.


(This post was edited by aniket on Dec 10, 2009, 6:37 AM)


shawnhcorey
Enthusiast


Dec 10, 2009, 6:53 AM

Post #2 of 3 (4326 views)
Re: [aniket] can any one tell how to validate correct email address using perl script [In reply to] Can't Post

Entering `email validation` in CPAN search gives 203 responses.

http://search.cpan.org/search?query=email+validation&mode=all

__END__

I love Perl; it's the only language where you can bless your thingy.

Perl documentation is available at perldoc.perl.org. The list of standard modules and pragmatics is available in perlmodlib.

Get Markup Help. Please note the markup tag of "code".


aniket
New User

Dec 10, 2009, 8:12 AM

Post #3 of 3 (4315 views)
Re: [shawnhcorey] can any one tell how to validate correct email address using perl script [In reply to] Can't Post

Shawn,

thank for your reply i was trying below code:

#!/usr/bin/perl -w

use Data::Validate::Email qw(is_email is_email_rfc822);

$emailid=<stdin>;

if(is_email($emailid))
{
print "Looks like an email address\n";
}
elsif(is_email_rfc822($emailid))
{
print ("Doesn't much look like an email address, but passes rfc822\n");
}
else

{
print ("Not an email address\n");

}

but some how i dont have this email.Pm ...How can i get that ?

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives