use strict;
use warnings;
my ($file, $handle, @arr);
open($handle, 'test.txt');
BREAKPOINT:
while (<$handle>) {
if (m/Here starts the second paragraph/) {
chomp;
push @arr, $_ for split /\s+/, $_;
while (<$handle>) {
chomp;
last BREAKPOINT if !$_;
push @arr, $_ for split /\s+/, $_;
}
}
}
print join "\n", @arr;
####
This is the start of the first paragraph.
This is the second line of this first paragraph.
And this is the last line of it.
Here starts the second paragraph.
This is the second line of this second paragraph.
And this is the last line of it.
Here starts the third paragraph.
This is the second line of this third paragraph.
And this is the last line of it.
Here starts the fourth paragraph.
This is the second line of this fourth paragraph.
And this is the last line of it.
####
Here
starts
the
second
paragraph.
This
is
the
second
line
of
this
second
paragraph.
And
this
is
the
last
line
of
it.