biohak has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Busting out of an inner loop to next file in foreach loop
by choroba (Cardinal) on Mar 10, 2014 at 14:04 UTC | |
by biohak (Initiate) on Mar 10, 2014 at 16:50 UTC | |
by LanX (Saint) on Mar 10, 2014 at 17:27 UTC | |
|
Re: Busting out of an inner loop to next file in foreach loop
by LanX (Saint) on Mar 10, 2014 at 14:22 UTC | |
|
Re: Busting out of an inner loop to next file in foreach loop
by kcott (Archbishop) on Mar 11, 2014 at 05:09 UTC |