go ahead... be a heretic | |
PerlMonks |
How can I extract the username and hostname/domain from e-mail addresses?by Symuc (Novice) |
on Nov 21, 2001 at 05:42 UTC ( [id://126701]=perlquestion: print w/replies, xml ) | Need Help?? |
Symuc has asked for the wisdom of the Perl Monks concerning the following question:
I'm working on a mailing list, and I need to do username validation. So far, I have the entire message read into a variable, and I'm using an (admittedly poor) split() to get the "From:" header. I know that RFC822 allows email addresses to be in formats other than the user@domain, such as the following: John Doe <jdoe@domain.com> -or- "'Jane Smith'" <jsmith@otherdomain.com> My question is this: How can I extract just the username and the hostname, preferably in separate variables? (And possibly, how can I use a regexp instead of the split() to extract the From: field?)
Back to
Seekers of Perl Wisdom
|
|