my $x = .... do { if ($whole =~ /^(.*?)^(\*{5,}..?^\*SRC)/mscg) { print "\n=======\n".$1."\n=======\n".$2; $x = $2; } } while($x);