>>>>> "Gunnar" == Gunnar Hjalmarsson <[EMAIL PROTECTED]> writes:
Gunnar> Or: This is a function I'm using in a couple of programs to check the
Gunnar> syntax, and that I believe is sufficient in practice:
Gunnar> sub emailsyntax {
Gunnar> return 1 unless
Gunnar> my ($localpart, $domain) = shift =~ /^(.+)@(.+)/;
Gunnar> my $char = '[^()<>@,;:\/\s"\'&|.]';
Gunnar> return 1 unless $localpart =~ /^$char+(?:\.$char+)*$/ or
Gunnar> $localpart =~ /^"[^",]+"$/;
Gunnar> $domain =~ /^$char+(?:\.$char+)+$/ ? 0 : 1;
Gunnar> }
No, that incorrectly invalidates
fred&[EMAIL PROTECTED]
which is a valid working address (try it! it's an autoresponder).
Just use Email::Valid. It has the right idea.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>