in reply to how to use matching operator on newlines

XY Problem - you don't need a matching operator. But you stated X and Y :-)

The simplest way is

perl -lp00 -i -e '' foo.txt

This sets $\ (output record separator) to "\n" and the input to paragraph mode ($/="\n\n" - more accurate qr{\n\n+}, it's like a regexp). That snippet squeezes multiple "\n"s into one, no matter how many. See perlrun.

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}