Hi Todd!

Glad to help and I'm happy that you have all the versions working to your satisfaction.

It is obvious that I like the last version because I added it to your test code. So now comes some of my opinion as opposed to "fact"... Why did I do that?

As I commented, white space doesn't consume any CPU cycles but it can be some of the most important "code" that you write. Just imagine if there wasn't a blank line between the 4 different "test" cases? That would make the source code a lot more difficult to understand! The computer doesn't care about white space, but humans do!

In the first case, I have to read through a bunch of substitutions before I finally come to the thing that is being modified at the very end of the line! In this case, I probably want to know that $NewRev is being modified first, not last. Usually, I read the details later if I care (and maybe I don't even care). On the first read of new code, I just want to get the general picture of what is going on. There are situations where this syntax and use of the comma operator makes sense. I just don't think that this is one of those cases.

I think the next couple of versions are "ok". But I like the last version best in this particular situation. What is being modified just "jumps out". It is easy for me to glance at the three statements that do the mods to get the idea of what they do or skip over them if I don't really care at the moment. By having a line for each regex, I can put a comment there, like perhaps # backward compatible, re bug #Q45983.

I know that a "style post" like this can generate controversy. I don't want to get into an extended discussion. I do encourage you to consider the issue and form your own opinion. "Compact" code does not necessarily equate to "fast" or "clear" code.


In reply to Re^5: Need help with loop syntax errors by Marshall
in thread Need help with loop syntax errors by Todd Chester

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.