in reply to multi-line match

It looks like you want the stuff between the headers as message, so this simple deal will build an array with indexes based on headers, if you want to preserve the newlines, just remove the chomp, otherwise process the array as you like:
use strict; my ($line, $i); my @messages; while(<DATA>){ my $hdr = 0; if(/header/){ $hdr = 1; $i++; } unless($hdr){ chomp; $messages[$i-1] .= "$_ "; } } print "$_ \n" for @messages; __DATA__ header This is messge one line 1. This is message one line 2. header Yet some more example text. Blah, blah.. Line 2 more blah, blah..

JamesNC