I'm trying to replace multiple lines in a text file (an XML element with an unknown number of children) with the contents of a separate text file. I've managed to get the replace mostly working using perl, but it's inserting an additional blank line after the string it replaces that i'd like to get rid of. See below for code showing the perl command as well as the input and replacement files.
Does anybody know how to prevent the additional blank line from appearing? I'm open to using other tools besides perl if necessary.
==> cat test.xml
<root>
<values>
<value>1</value>
<value>2</value>
<value>3</value>
</values>
</root>
==> cat replace.xml
<values>
<value>4</value>
<value>5</value>
</values>
==> perl -i -p0e 's;<values>.*<\/values>;`cat replace.xml`;sge' test.xml
==> cat test.xml
<root>
<values>
<value>4</value>
<value>5</value>
</values>
</root>
==>