If you want to compare Perl with grep you need to compare the same behaviour.
Your grep uses -z ("Treat the input as a set of lines, each terminated by a zero byte (the ASCII NUL character) instead of a newline."). So it breaks the "classical" definition of a line.
I do not see something similar in your perl command. So it uses the "classical" line definition. At the same time, I think, your Regex in the perl command would not match a newline character with the '.', because it does not use the /s modifier.
In reply to Re: Unable to match newline
by linuxer
in thread Unable to match newline
by robinson
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |