title: Perl Code required to break loop when key pressed
body: <p>I have a script which gets executed, but I require a loop which tells the process to sleep for 20-30 secs whilst a user runs a different test.  </p>
  
  <p>Once that test is completed then the user presses <kbd>Enter</kbd> to continue from where the script was halted. If <kbd>Enter</kbd> is not pressed within the 20-30 second period the script is to continue to run without user input.</p>
  
  <p>I tried the following code but it pauses the script indefinitely – it does not continue after 20 secs, but it also does not accept <kbd>Enter</kbd>.</p>
  
  <pre><code>use Term::ReadKey;
  ReadMode 4;
  do {
      sleep 20; 
  } until ( defined( $key = ReadKey(-1) ) );
  ReadMode 0;
  </code></pre>