A tricky question, and one that usually has me trying to avoid the need for a post condition in the first place.

LOOP: .. goto LOOP if is completely out of the question ever since I grew out of BASIC. :)

redo if uses an unnamed block that to me signals "short term lexical variables required for the next couple of lines", not "postcondition loop here" when I'm reading the code.

continue has the disadvantage of a massive performance hit, so I only resort to it when I need its special property that the continue-block is executed regardless of where or how the main loop's body was exited. Which so far, was never.

do while would be the natural way to go about it, but has the disadvantage that you cannot use next and co in the (non)loop body. It's ok for short loops though.

Thus, while(1) last if is what I'd do most of the time.

However, these calls are just mine; I can see that someone else might disagree with them. Basically, since there's no "real"/"official" postcondition loop construct in Perl, it is mostly up to you. The only thing I will "insist" on is to immediately forget the goto form - but I guess you knew that anyway.

Makeshifts last the longest.


In reply to Re: Perl style question: loops with postcondition by Aristotle
in thread Perl style question: loops with postcondition by IlyaM

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.