I have a file foo.txt
hello world
first line to change
second line to change
I would like to write a perl one-liner that changes foo.txt to read
hello world
this is
my new text
I tried
perl -p -i -e 's/ first line to change\n second line to change/ this is\n my new text/g' foo.txt
but this script does nothing to the file. What's wrong with my one-liner?