title: Perl system command not acting as a normal prompt
body: <p>I am trying to modify a perl script to comment out all lines matching some pattern. In normal command prompt, here is the line I'm trying to add: </p>
  
  <pre><code>grep -lIRZ --exclude="*\.svn*" "pattern" . | xargs -0 -l sed -i -e 's/.*pattern.*/\/\/&amp;/g'
  </code></pre>
  
  <p>Here it is in the context of the perl script:</p>
  
  <pre><code>my $rmcmd = "grep -lIRZ --exclude=\"*\\.svn*\" \"pattern\" . | xargs -0 -l sed -i -e 's/.*pattern.*/\\/\\/&amp;/g'";
  runcmd($rmcmd);
  ...
  sub runcmd {
      my @cmd = @_;
      print "Running: @cmd\n";
      system(@cmd);
      # Get  status from system
      my $ret = $? &gt;&gt; 8; 
  
      if ($ret) {  
          print "-E- command completed with error code $ret.\n"; 
          exit(1); 
      }
      return ($ret);
  }
  </code></pre>
  
  <p>Everything works properly when run from a command prompt, but the script running the same command always crashes.</p>
  
  <p>What is being done differently and how can I fix it?</p>