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


in reply to Reading "slices" out of a file at known start markers

Another way to do it:

while ( <FH> ) { if ( /^SOURCES/ && /\\$/ ) { $_ .= <FH>; redo; } elsif ( /^SOURCES/ ) { print; } }

And yet another way:

my $data; while ( <FH> ) { $data .= $_ if /^SOURCES/ || $data && /^\s/; last if $data && !/\S/; } print $data;