Linux / UNIX Tech Support Forum
This is a discussion on Email validation in Perl Code Sample within the Coding in General forums, part of the Development/Scripting category; Dear All, Can anybody tell me how to validate email address in perl. Thanks,...
|
|||||||
| Coding in General Discussion on PHP/Perl/Python/Ruby/GNU C or C++. MySQL, PgSQL and (X)HTML or any other programming languages you want. |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
| Sponsored Links | ||
|
|
|
||||
|
You cannot do real-time validation of deliverable mail addresses. Most common pattern is as follows:
Code:
while $addr =~ s/\([^( )]*\)//g; Code:
if ($email_address =~ /^(\w¦\-¦\_¦\.)+\@((\w¦\-¦\_)+\.)+[a-zA-Z]{2,}$/)
{
print "$email_address is valid";
}
else {
print "$email_address is invalid";
}
I Knew How To Validate An Email Address Until I Read The RFC |
|
|||
|
Dear Monk,
It is not validating email id. #!/usr/bin/perl $email = "chndan.kumar@yahoo.co.in"; if ($email_address =~ /^(\w\-\_\.)+\@((\w\-\_)+\.)+[a-zA-Z]{2,}$/) { print "$email_address is valid"; } else { print "$email_address is invalid"; } |
|
||||
|
Quote:
Code:
$email = "chndan.kumar@yahoo.co.in"; Code:
$email_address = "chndan.kumar@yahoo.co.in"; Quote:
Here is updated code for you: Code:
#!/usr/bin/perl -w
$email_address = 'chndan.kumar@yahoo.co.in';
if ($email_address =~ /^(\w\-\_\.)+\@((\w\-\_)+\.)+[a-zA-Z]{2,}$/)
{
print "$email_address is valid";
}
else {
print "$email_address is invalid";
}
__________________
Vivek Gite Linux Evangelist Last edited by nixcraft; 12-09-2008 at 04:52 PM. |
![]() |
| Tags |
| email validation , perl , perl email validation , regex , unix |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| convert perl code into binary executable | chandanperl | Coding in General | 2 | 12-01-2010 01:03 PM |
| how to send email on every saturday in perl | chandanperl | Coding in General | 4 | 22-08-2008 06:25 PM |
| RHCE Exam Sample Papers | vikas027 | CentOS / RHEL / Fedora | 2 | 25-03-2008 05:51 PM |
| sample scripts for FTP in Unix | jerry | Shell scripting | 1 | 23-06-2006 11:01 PM |
| RHCE sample questions require | puppen | Linux software | 3 | 13-04-2006 06:36 PM |