G'day biohak,

Welcome to the monastery.

Firstly, please don't alter your OP without indicating what you've changed. See "How do I change/delete my post?" for an explanation of why not and how to indicate changes.

The code you currently have posted has many issues:

Using this dummy data (as I've no idea what your real data looks like):

$ cat pm_1077685_A.txt Line 1: no plate info Line 2: ... PlateID 123 ... Line 3: ... PlateID 456 ... Line 4: no plate info $ cat pm_1077685_B.txt Line 1: no plate info Line 2: ... PlateID 789 ... Line 3: ... PlateID ... Line 4: no plate info $ cat pm_1077685_C.txt Line 1: no plate info Line 2: ... PlateID 000 ... Line 4: no plate info

This script shows similar processing to what you appear to be attempting and includes examples of the points I've made above.

#!/usr/bin/env perl use strict; use warnings; use autodie; my @filenames = qw{pm_1077685_A.txt pm_1077685_B.txt pm_1077685_C.txt} +; for my $filename (@filenames) { my $in_path = "./$filename"; print "Processing: '$in_path'\n"; open my $in_fh, '<', $in_path; while (<$in_fh>) { print "\t$_"; if (/PlateID/) { if (/PlateID (\d+)/) { my $plate_id = $1; print "\t\tProcess PlateID '$plate_id' from '$in_path' +\n"; } else { print "\t\tpopup_error_window($in_path)\n"; last; } } } }

Output:

$ pm_example.pl Processing: './pm_1077685_A.txt' Line 1: no plate info Line 2: ... PlateID 123 ... Process PlateID '123' from './pm_1077685_A.txt' Line 3: ... PlateID 456 ... Process PlateID '456' from './pm_1077685_A.txt' Line 4: no plate info Processing: './pm_1077685_B.txt' Line 1: no plate info Line 2: ... PlateID 789 ... Process PlateID '789' from './pm_1077685_B.txt' Line 3: ... PlateID ... popup_error_window(./pm_1077685_B.txt) Processing: './pm_1077685_C.txt' Line 1: no plate info Line 2: ... PlateID 000 ... Process PlateID '000' from './pm_1077685_C.txt' Line 4: no plate info

-- Ken


In reply to Re: Busting out of an inner loop to next file in foreach loop by kcott
in thread 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.