title: How can I limit the time spent in a specific section of a Perl script?
body: <p>Is there any way to build some time counter that enable parts of a script to run as long it ticks? For example, I have the following code:</p>
  
  <pre><code>for my $i (0 .. $QUOTA-1) {
      build_dyna_file($i);
      comp_simu_exe;
      bin2txt2errormap($i);
  }
  </code></pre>
  
  <p>Theoretically I want to run this loop for 3 minutes, even if the loop instructions haven't finished yet, it should still break out of the loop after exactly 3 minutes.</p>
  
  <p>Actually the program opens a time counter window that works in parallel to part of the script (each time I call it).</p>
  
  <p>Additionally, the sub call 'comp_simu_exe' run an outside simulator (in the shell) that when time out ends - this process must also killed (not suppose to return after a while).</p>
  
  <pre><code>sub comp_simu_exe{
  
  system("simulator --shell");
  }
  </code></pre>
  
  <p><strong>Is there any connection between the dead coming problem to the system function call ?</strong></p>