The continue block is guaranteed to be executed in each iteration.
my $i = my $j = 0; while ($i++ < 5) { next if $i == 2 || $i == 4; print "i:$i\n"; } continue { $j++; printf "j:$j\n"; }
See that the i line is not always printed because it depends on if checking, while j line is always printed regardless what happens inside the while block*. This won't happen if printing j line is put inside the block as i.

But frankly, I never use continue myself in practical. It exists for some reason regarding the for loop (see Programming Perl). From the doc:

"last", "next", or "redo" may appear within a "continue" block. "last" and "redo" will behave as if they had been executed within the main block. So will "next", but since it will execute a "continue" block, it may be more entertaining.
Some monk commented on that emphasized text but I can't recall the node.

* Unless redo take place, as shown by GrandFather below. The same thing with last. Consider,

my $yodda = 0; while ($yodda < 6) { last if $yodda == 5; redo if ++$yodda & 1; print "Even is "; } continue { print "$yodda\n"; }

Update: added note following correction by GrandFather

Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!


In reply to Re: What could be the exact usage of While - continue loop by naikonta
in thread What could be the exact usage of While - continue loop by jesuashok

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.