Your solution is probably looking for a way to methodically parse out the headings and data for each section, rather than look for only a specific one.
For that, you would want to use a zero width look ahead assertion (?=regexp).
One assumption, the headings aren't always (but usually) indented with 5 spaces. Line items are always indented with 9 spaces.
Here's what I came up with that worked for me on ActivePerl 5.6.
use strict;
my $data = join("", <DATA>);
print "data:\n$data";
# loop for each heading
while ($data =~ /\s*(.*?):\s*\n((.|\n)*?\n)(?=(\s*\w+:|\Z))/gc) {
print "heading: $1\n";
my $text = $2;
while ($text =~ /\s{9}(.*?)\n/gc) {
print "line item: $1\n";
}
}
exit;
__DATA__
Paragraph1:
text
Paragraph2:
text1
text2
text3
Paragraph3:
text