Apologies if this is a newbie question, I havent been able to find a solution online. I have a loop that iterates through an array of filenames and I would like to break out of a nested loop to the next file in @filnames. I must be overlooking a simple solution or method that I am not aware of. I added the goto statement hoping to return to the outer loop, but I found this just restarts from the beginning of the foreach which is not what I wanted. edit: I noticed the label was on the line above the foreach loop. After moving inline with the loop, it is working properly. Thanks for the help, TIA

RECORD: foreach my $filenames (@filenames) { my $XML_infile = "C:/_OUTPUT/$filenames"; chomp $XML_infile; open INDATA, "C:/_OUTPUT/$filenames" or die "INDATA: $! \n\n "; while (!eof INDATA ) { my $line = <INDATA>; if ( $line =~ /\"PlateID\"/g ) { $outfile= ">C:/_OUTPUT/_DATA/$filenames" . $plate_id . ".t +xt"; if ( ($plate_id eq '' ) or ( ($FAM eq '' ) && ($VIC eq '' +) ) ) { popup_error_window($XML_infile) ; #Jump to next file in @filenames from here next RECORD; #Duh was staring right at me. } elsif () {#pull data for PlateID} } elsif () {#Process rest of file } } #complete processing data }#endforeach

In reply to Busting out of an inner loop to next file in foreach loop by biohak

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.