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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |