MAIN_LOOP: is a label and is the target of constructs like next MAIN_LOOP; and last MAIN_LOOP;. However, unless you have nested loops and need "next" or "last" to apply to the outer loop, labels very seldom need to be used. Consider:

use strict; use warnings; MAIN_LOOP: for my $number_to_check (1 .. 20) { for my $colour ('red', 'green', 'black') { next MAIN_LOOP if $number_to_check % 3 and $colour eq 'green'; print "$colour-$number_to_check "; } print "\n"; }

prints:

red-1 red-2 red-3 green-3 black-3 red-4 red-5 red-6 green-6 black-6 red-7 red-8 red-9 green-9 black-9 red-10 red-11 red-12 green-12 black-12 red-13 red-14 red-15 green-15 black-15 red-16 red-17 red-18 green-18 black-18 red-19 red-20

Perl reduces RSI - it saves typing

In reply to Re: How Do I Use Labels? by GrandFather
in thread How Do I Use Labels? by baurel

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.