Randal L. Schwartz wrote:
"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

I never claimed the function to be perfect, and I said in practice. Noone is using such an address in real life unless they are asking for trouble; I'm sure you don't either.


Randal, you have that address only to demonstrate shortcomings in various attempts to check email syntaxes, right? ;-)

Just use Email::Valid. It has the right idea.

I suggested that also, but the reason I don't use it in those two programs I mentioned is that the programs are publicly available for downloading, and I always think twice before making such programs dependent on non-standard modules.


--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to