Yeah, I understand and agree explicit code can be good sometimes but my pseudo-code was arbitrarily picked to show how the same exact task could be made more difficult to follow by being too verbose. There is no ambiguity in the AM's answer above and your version was harder to read and therefore more likely to disguise bugs and poor optimization/operator choices; which it has and it does compared to the original answer. Your solution drops anything other than ASCII alphanumerics and, bizarrely, commas; and regular expressions are a confusing and sub-optimal choice for single character looping and comparisons.

Things like a next as the last instruction in a loop is explicit to the point of... well, it's so obvious, it becomes distracting noise. Overly verbose or simplistic becomes confusing (What? Why would anyone do that? I must be missing something, better read this again five times) or talking down. Talking down to other devs is a good way to make them slowly despise you.

Put another way: elegant code lifts me up, makes algorithms obvious, condenses ideas into easily assimilated blocks, saves me time, and helps make me become a better hacker; simplistic code doesn't. I don't like golf in the code base more than anyone else but I sure as monkeys prefer a Schwartzian transform over 4 back to back for loops.

(Update: I missed the rest of the thread earlier that already covered some of this. Sorry about that. I also think this reads harsher than I meant. I do agree that code can be made explicit to everyone's benefit; just wanted to say that explicitness for its own sake is self-defeating.)


In reply to Re^4: Regex question by Your Mother
in thread Regex question 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.