http://qs321.pair.com?node_id=1213414


in reply to Re^4: Getting lines in a file between two patterns
in thread Getting lines in a file between two patterns

Push lines to an array, clear it at each START.

#!/usr/bin/perl use strict; my $flag = 0; my @lines = (); while (<DATA>){ if (/^\s*END/){ $flag = 0 } elsif (/^\s*START/){ $flag = 1; @lines = (); } elsif ($flag) { push @lines,$_; } } print join '',@lines;
poj