title: Perl substitution from Python in Anaconda on Windows platform
body: <p>In an Anaconda shell environment on Windows with perl, m2-base and maybe some other packages installed:</p>
  <pre><code>$ echo &quot;/&quot; &gt; junk
  $ more junk
  &quot;/&quot;
  $ perl -pi.bak -e &quot;s/\&quot;\/\&quot;/\&quot;\\\\\&quot;/&quot; junk
  $ more junk junk.bak
  ::::::::::::::
  junk
  ::::::::::::::
  &quot;\&quot;
  ::::::::::::::
  junk.bak
  ::::::::::::::
  &quot;/&quot;
  </code></pre>
  <p>I want to replicate this in Python. My script is this:</p>
  <pre><code>import subprocess
  cmd = 'perl -pi.bak -e &quot;s/\&quot;\/\&quot;/\&quot;\\\\\&quot;/&quot; junk'
  subprocess.call(cmd, shell = True)
  </code></pre>
  <p>which gives the following output:</p>
  <pre><code>$python test_perl.py
  Substitution replacement not terminated at -e line 1.
  </code></pre>
  <p>I have tried different combinations of backslashes, different quotation styles, and using a different delimiter in perl (i.e. replacing the <code>/</code> with something like <code>@</code>), but can't seem to figure out how to crack this nut.</p>
  <p><strong>UPDATE</strong></p>
  <p><code>subprocess.call(['perl', '-pi.bak', '-e', &quot;s!\\\&quot;\/\&quot;!\&quot;\\\\\\\&quot;!&quot;, 'junk'], shell = True)</code> works, but I'm confused about why <code>subprocess</code> does not need extra quotes to encapsulate the perl switch statement. Any insights would be appreciated.</p>
  <p>--</p>
  <p>For more info on what I'm actually doing, I am trying to install a Python module that was designed for Linux/Unix on my Windows platform in an Anaconda environment. For one part, I need to replace &quot;/&quot; with &quot;\&quot; in some of the files of the module. I am aware that I could edit the files directly and use something like <code>os.path.split</code> instead of just <code>split(&quot;/&quot;)</code> but I am trying to create a file that does all the work, so all one needs to do is clone the git repository and run a setup script.</p>