title: Execute perl script with arguments in R
body: <p>I have a perl script (SFDRv166.pl, available here <a href="http://bit.ly/1DGmUTL" rel="nofollow">http://bit.ly/1DGmUTL</a>) that I run successfully from the command line using:</p>
  
  <pre><code>perl SFDRv166.pl -assoc input.txt -SFDR -out test
  </code></pre>
  
  <p>I now need to run this program as part of an R script, and have tried implementing it as follows:</p>
  
  <pre><code>arg1 &lt;- shQuote("-assoc input.txt")
  arg2 &lt;- shQuote("-SFDR")
  arg3 &lt;- shQuote("-out test")
  
  system("perl SFDRv166.pl arg1 arg2 arg3")
  </code></pre>
  
  <p>However, I get an <code>ERROR: cannot find !</code> message generated I believe because the arguments are not getting passed to the perl script (output says no input or output file specified, and no output is created). </p>
  
  <p>I can see from reading the documentation for <code>system()</code> that arguments with spaces require special handling, which is why I have tried to use <code>shQuote()</code>. Not sure what else may be wrong with my approach?</p>