It is opaque for two reasons:

1/ because the comma operator is seldom used so little understood. I don't mean by you (or me even - I have occasionally used it in the past), but in general. (I know this because of the complaints I've received from co-workers when I've used them - "Are you allowed to do that!".)

2/ because the comma as operator is hard to see compared to how important its correct interpretation is to understanding the code. Most often commas are used in lists and tend to be treated as something the parser needs to do its job, but are essentially ignored by people reading the code - white space and layout are generally much better cues for understanding the form of the code.

Regardless of how a loop is structured you have to read the code to see how it terminates. I'd rather use a C/C++ do {...} while (...); construct than the while (1) {...} loop for this sort of problem where appropriate, but Perl doesn't provide that directly. In fact it's not appropriate in the code being discussed anyhow due to the print at the end of the loop.

Putting the termination test at the top of a loop is fine if you can do it. Where I used while (1) you can't provide a termination test because the information doesn't exist yet. However the exit conditions for the sub (and thus the loop) are very easy to see and the while (1) loop construct provides exactly the right signal - do it forever until something within the loop causes it to stop (disregarding someone putting an axe through the computer or other such event of course).

Using the comma operator to avoid a few statements is not a good argument unless it really does make the code clearer. In practise I don't recall a single case where using the comma operator made code clearer. I do however remember some nasty cases where it made the code less clear and introduced really hard to find bugs.


True laziness is hard work

In reply to Re^4: Use of uninitialized value in addition by GrandFather
in thread Use of uninitialized value in addition by Solarplight

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.