my(@all, $cur); while () { if ($_ =~ /\ADELIMITING_TEXT\Z/) { push @all, $cur; $cur = ""; } else { $cur .= $_; } } push @all, $cur;