Also some Regexps are broken or inefficient.

my %spec = ( username => qr#^[A-Za-z][-.\w]{2,29}$#, domain => qr#^(a|c|f|h|ho|i|k|o|s|x)\.com$#, email => qr#^[\w\.\-]+\@(?:[a-z\d\-]+\.)+[a-z\d]+$#i, service => qr#^Yes|No$#, conditions => qr#^Yes$#, );

These regexes allow for a newline after the last character. This could lead to trouble, for example when assuming your log file consists of one line with fields seperated by commas (as one probably would).

The regex for domains assumes all domains are .com, which they are not. Apart from that, it can be written in a more efficient way.

Your service regex is flawed: it allows for any string as long as it starts with Yes or ends with No (and optional newline).

Also, there's no need to escape a dash (like you do in the email regex) if you put it at the beginning or end of a character class.

In summary, I'd write those as:

my %spec = ( username => qr/^ [A-Za-z] [-.\w]{2,29} \z/x, domain => qr/ ^h\.net\z | ^(?:ho | [acfikosx])\.com)\z /x, email => qr/^ [\w\.-]+ \@ (?:[a-z\d-]+\.)+ [a-z\d]+ \z/ix, service => qr/^(?:Yes|No)\z/, conditions => qr/^Yes\z/, );

— Arien


In reply to Re: Re: Peruse my code... by Arien
in thread Peruse my code... by Anonymous Monk

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.