title: How to get started multithreading in Perl
body: <p>I have a perl program that takes over 13 hours to run.  I think it could benefit from introducing multithreading but I have never done this before and I'm at a loss as to how to begin.  </p>
  
  <p>Here is my situation:
  I have a directory of hundreds of text files.  I loop through every file in the directory using a basic for loop and do some processing (text processing on the file itself, calling an outside program on the file, and compressing it).  When complete I move on to the next file.  I continue this way doing each file, one after the other, in a serial fashion.  The files are completely independent from each other and the process returns no values (other than success/failure codes) so this seems like a good candidate for multithreading. </p>
  
  <p>My questions:</p>
  
  <ol>
  <li>How do I rewrite my basic loop to take advantage of threads?  There appear to be several moduals for threading out there.</li>
  <li>How do I control how many threads are currently running?  If I have N cores available, how do I limit the number of threads to N or N - n?  </li>
  <li>Do I need to manage the thread count manually or will Perl do that for me?</li>
  </ol>
  
  <p>Any advice would be much appreciated.</p>