title: Timing out with alarm when waiting on input on Perl in Windows
body: <p>Is there an alternative for alarm function in Perl to be used on Windows? </p>
  
  <p>Alarm doesn't seem to work in Windows. </p>
  
  <p>The below code should timeout if no user input is given within N seconds. The code works good in linux but hangs in there on Windows.</p>
  
  <p>CODE:</p>
  
  <pre><code>$SIG{ALRM} = \&amp;input_timed_out;
  
  eval {
  
          alarm(10);
  
          $input = &lt;&gt;;
          alarm(0);   
          print $input."\n";
  }
  
  print "eval exit with:  $@  \n";
  
  if ( $@ =~ /NO USER INPUT IN TIME/ ) {
  
         print "Timed out.\n";
         $input = "quit";
  }
  
  print "Answer is $input\n";
  
  sub input_timed_out {
  
             die "NO USER INPUT IN TIME";
  
  }
  </code></pre>