`perl -0pe` wants `.\n^`, not `.$\n^`
11:14 18 Apr 2026

I am confused.

cat << EOF > test.txt
this
is
a
text
file
EOF
cat test.txt | perl -0pe 's/.\n^text/hellohello/smg'

works, but

cat test.txt | perl -0pe 's/.$\n^text/hellohello/smg'

doesn't.

Annoyingly https://regex101.com/ doesn't detect this quirk. Is it to do with -0? And why would $\n^ syntax (which is usually perfectly fine) be wrong anyway?

perl command-line-interface multiline regexp-replace null-character