I am unsure about what you are trying to accomplish. I of course can't run your code as an example. I just didn't understand it.

UPDATE: OMG, I got along the wrong track because of your original code which appeared to have several nested loops. The right Perl thing to "exit a single loop" is: last. You need a Label to jump a couple of levels up! But not here! Sorry about the confusion!

#!/usr/bin/perl use warnings; use strict; my @x = ( ['aaaaa', 'bbbbb', 'ccccc', 'ddddd',], ['eeeee', 'fffff', 'ggggg', 'hhhhh',], ['iiiii', 'jjjjj', 'kkkkk', 'lllll',], ); #@x is a 2D array, an AoA (Array of Array) OUTER: for my $row_ref (@x) { for my $element (@$row_ref) { # call exit(1) to competely stop! # with error code 1 if ($element eq 'ggggg') { print "stop seen\n"; next OUTER; #last; would work here } else { print "$element\n"; } } } __END__ Prints: aaaaa bbbbb ccccc ddddd eeeee fffff stop seen iiiii jjjjj kkkkk lllll
See also Perl "redo"....

In reply to Re: returning to the outer loop by Marshall
in thread returning to the outer loop by Anonymous Monk

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.