in reply to Validate CGI data

sub is_email { return sub { return $_[0] =~ m{^[-.+a-z0-9]+\@[-.+a-z0-9]+$}i; }; }
One reason not to reinvent the wheel is to not make the same common mistakes. You're making the common mistake here. Please understand RFC 822 before writing a routine like this. Or just use something like Email::Valid to get it right.

Your code downvoted. Ugh.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Replies are listed 'Best First'.
Re^2: Validate CGI data
by marcelo.magallon (Acolyte) on Jun 26, 2005 at 20:36 UTC

    Fair point.

    I want a local part plus domain, not a full blown email address. Yes, I know I've got even that wrong in the presented code. And, although valid, I really don't want to deal with "My Name"@example.org nor I want to deal with nulls embedded in the local part.

    Is there room for improvement? Yes, sure. But that really wasn't the point of the original post.

    Thanks!
      Is there room for improvement? Yes, sure. But that really wasn't the point of the original post.
      OK, then I'm confused. If you post code here, the implication is that you're posting your code for peer review and comment, in the intent to improve it or find the holes. So, I make a comment, and then you say "that's not the point of the original post". You are clear on what postings here are about, right?

      -- Randal L. Schwartz, Perl hacker
      Be sure to read my standard disclaimer if this is a reply.