On Oct 24, 2013, at 11:59 AM, Ronald F. Guilmette wrote:

> But, getting back to my original 2 questions...
> 
> I want to stress that I did not ask how to formulate and/or send a
> properly formatted e-mail message.  I can handle that part, even if
> perhaps only in my own clumsey way.
> 
> What is of more interest to me, again, is the question of how to properly
> validate (a) a string that's given on a form and which is meant to
> represent a person's name, an also (b) a string that is given in a form
> and that is supposed to represent a person's e-mail address.
> 
> Assume that I want to do both these things *and*, to the maximum extent
> possible, I want to reject any & all strings that are implausible name
> and/or e-mail address strings.
> 
> How?  What's the code to do each of these things.
> 
> These certainly should both be well-solved problems by now, but in case
> they aren't, I'd like to take my own humble wack at developing good
> solutions for both problems.

See the advice in Perl FAQ #9 "How do I check a valid mail address?"

The command 'perldoc -q address' will get you that entry.

Synopsis: it is difficult to write a regular expression to parse and validate 
an email address. The modules Email::Valid and RFC::RFC822::Address might help.

I usually just check to see if the string contains the '@' character. I might 
also delete any character that is not in [a-zA-Z0-9.:;_@<>-] (but see the 
longer RE in the FAQ).
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to