Is there any way round to that i can write the following sub routine only once and check two different user input emails for validation with custom error messgas for each?
sub check_email {
$email = $in{'friends_email'} ;
if ($email =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ ||
$email !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/) {
return 0;
}
else {
return 1;
}
}
I am using the following code to call this sub routine:
if(!&check_email(email)){
Print "ERROR: Invalid Email Entered In \"Friend's Email\" Field";
}
Now i want to use the same sub routing to validate another user input email -- $in{'referrer_email'}. Is this possible in any manner? Or is there any other way round to doing it.
Presently I have written the same sub routine with another name and the first line of it changed to
$email = $in{'referrer_email'} ;
NOTE: I want to 'print' custom error message for each of them.
sub check_email {
$email = $in{'friends_email'} ;
if ($email =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ ||
$email !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/) {
return 0;
}
else {
return 1;
}
}
I am using the following code to call this sub routine:
if(!&check_email(email)){
Print "ERROR: Invalid Email Entered In \"Friend's Email\" Field";
}
Now i want to use the same sub routing to validate another user input email -- $in{'referrer_email'}. Is this possible in any manner? Or is there any other way round to doing it.
Presently I have written the same sub routine with another name and the first line of it changed to
$email = $in{'referrer_email'} ;
NOTE: I want to 'print' custom error message for each of them.