title: Perl: execute 10 system processes async
body: <p>This question is for running perl on windows 2012 server.</p>
  
  <p>So I have a folder called Commands_To_Run and under there are 100 batch files e.g.</p>
  
  <pre><code>Commands_To_Run
   - run_1.bat
   - run_2.bat
   - run_3.bat 
  ...
   - run_100.bat
  </code></pre>
  
  <p>Each of these run*.bat files take about 30 mins to complete. If I run these batch files serially using a FOR loop then it takes me 100 * 30 min to run. (Too long!)</p>
  
  <p>What I want to is write a perl script that will execute 10 batch files at a time. Once any one of the batch files complete the next batch file would get executed. </p>
  
  <p>For example I would like to execute run1.bat through run10.bat. Let's say run7.bat finishes then I want to run next run11.bat and so on. So there are 10 files running at any given time. </p>
  
  <p>I thought about using this perl script to run batch file but this will run all 100 at the same time and it will kill my windows CPU &amp; processing.</p>
  
  <pre><code>for ($x=0; $x &lt; scalar(@files); $x++ ) {
      $file=@files[$x];
      chomp $file;
      $cmd="start $file ";
      print "Runnung Command is: $cmd\n";
      system($cmd);
  }
  </code></pre>
  
  <p>I looked at the suggestion given but there is no working example of how to use use Forks::Super </p>