perl -pi -e 'BEGIN { $/ = undef } s/foo/bar/g' file1.txt file2.txt ...