in reply to multiline inplace edit

I usually do this and I get the same result without a script.

perl -i -0pe 's/foo/bar/g' file1 file2