I skipped the specification's "domain-literal" alternative, at least for the time being.
This is the modified function:
sub emailsyntax { return 1 unless my ($localpart, $domain) = shift =~ /^(.+)@(.+)/; my $atom = '[^[:cntrl:] "(),.:;<>@\[\\\\\]]+'; my $qstring = '"(?:\\\\.|[^"\\\\\s]|[ \t])*"'; my $word = qr($atom|$qstring); return 1 unless $localpart =~ /^$word(?:\.$word)*$/; $domain =~ /^$atom(?:\.$atom)+$/ ? 0 : 1; }
my $test = 'fred&[EMAIL PROTECTED]';
print "$test is ", emailsyntax($test) ? 'not ' : '', "ok.\n";
Looking forward to your critique.
-- 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>