in reply to Breaking out of a matching block

Something like
my $abort = 0; while (<$fh>) { chomp; if ($_ eq 'START' .. $_ eq 'END') { if ($abort) { $abort = 0 if substr($_, -2) eq 'E0'; next; } ... if (!/cool data/gi) { $abort = 1; next; } ... } }

Of course, it would be much simpler, safer, robust and clearer if you used an XML/HTML parser since you appear to be trying to parse XML/HTML.