http://www.perlmonks.org?node_id=1203084


in reply to [Solved]Need to extract a particular block of lines between two patterns

Use the return value of the flip-flop:
my $count; while (<$fh_r>) { if (my $status = /START/ .. /END/) { $count++ if $status == 1; print if $count == 2; } }