yoda54 has asked for the wisdom of the Perl Monks concerning the following question:
How does one break out a segment of lines if it doesnt match a certain criteria?
For example, I've got a text file like this:
START
important data
important data
END
START
Nothing interesting here, skip the rest of this start and end.
STOP
START
important data - more cool stuff continue here
important data - ditto
END
As I'm pulling data in between the start and end blocks, if I find nothing I need for a particular start/end range then how can I just skip entirely and start on the next START segment?
Thanks for any help!!
while(<F>) { chomp; if (/^<START/.../^<\/END/) { if ($_ !~ m/cool data/gi) { break this current START ... END block } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Breaking out of a matching block
by ikegami (Patriarch) on Feb 09, 2010 at 07:31 UTC | |
|
Re: Breaking out of a matching block
by Marshall (Canon) on Feb 09, 2010 at 05:44 UTC |