I am pretty new to Perl. I already love it! I needed to validate what a human operator states it is his email address, and I needed to avoid module installation. I have been tuning this function for a while and it seems to be quite good both in picking out bad formed addresses and in giving very few false positives. I hope it can be useful to someone. I would thank those who can suggest improvements too.
sub es_email_mal_formado { my $x = $_[0]; if ($x =~ m/[^\w\@\.\-]/) {return "Incluye un carácter prohibido" +}; if ($x =~ m/\W\W/) {return "Tiene dos no alfanuméricos seg +uidos"}; if ($x =~ m/\@.+\@/) {return "Tiene más de una arroba"}; if (! ($x =~ m/\w\@\w/)) {return "No tiene arroba precedida y se +guida de alfanumérico"}; if (! ($x =~ m/\w\.\w/)) {return "No tiene punto precedido y seg +uido de alfanumérico"}; if (! ($x =~ m/\@.+\./)) {return "No tiene punto en la parte que + sigue a la arroba"}; if ($x =~ m/^\W/) {return "Empieza en no alfanumérico"}; if (! ($x =~ m/\.\w{2,4}$/)) {return "No tiene \"de 2 a 4 alfanuméri +cos\" al final"}; if ($x =~ m/(\@|\.).\.\w+$/) {return "Tiene una sola letra antes del + último punto"}; return 0; }

In reply to Poor man's email address validation function by Jorge_de_Burgos

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.