title: Replace multiline string in all files in terminal
body: <p>I have a couple of files in a directory, in which I have a piece of text between two separators.</p>
  
  <pre><code>Text to keep
  
  //###==###
  Text to remove
  //###==###
  
  Text to keep
  </code></pre>
  
  <p>After an extensive search, I found the following Mac OS X Terminal command, with which I can remove the separators themselves.</p>
  
  <pre><code>perl -pi -w -e 's|//###==###||g' `find . -type f`
  </code></pre>
  
  <p>However, I need something with a regex that does not only remove the separators themselves, but also what is in between. Something like this, although this line doesn't do anything.</p>
  
  <pre><code>perl -pi -w -e 's|//###==###(.*)//###==###||g' `find . -type f`
  </code></pre>
  
  <p><strong>EDIT AFTER DUPLICATE FLAG</strong></p>
  
  <p>I see something similar <a href="https://stackoverflow.com/questions/2146745/how-should-i-use-perls-scalar-range-operator">here</a>, using the scalar range operator, but I cannot make it work for me. Failed attempts include:</p>
  
  <pre><code>perl -pi -w -e 's|//###==###..//###==###||g' `find . -type f`
  perl -pi -w -e 's|//###==###(..)//###==###||g' `find . -type f`
  perl -pi -w -e 's|//###==###[..]//###==###||g' `find . -type f`
  </code></pre>
  
  <p><strong>SOLUTION</strong></p>
  
  <p>With the help of dawg below, the following oneliner will do exactly what I want:</p>
  
  <pre><code>$ perl -0777 -p -i -e 's/(^\s*^\/\/###==###.*?\/\/###==###\s*)//gms' `find . -type f -name "index.php"`
  </code></pre>