my $not_followed_by_end_p = qr{(?:(?!

).)*}s; while (<>) { s{ (

(?=$not_followed_by_end_p\n\n) $not_followed_by_end_p

) }{-->$1<--}gx; print; }