sub get_stdin_w_timeout { ######!/usr/bin/perl #got from zentara on perl monks in response to Timeout on STDIN #modifying to use ReadKey to get first key and then to get the rest of the line #this function assumes that once there is some input on stdin, #the rest of the line is available too use strict; use warnings; use Term::ReadKey; my $timeout_in_sec=shift; my $end_time = time + $timeout_in_sec; my $key=""; do { my $key = ReadKey(1); if (defined $key) { #not sure if I need to concatenate $key on the front of return $key. ; } } while (time < $end_time ); return "!ERROR!:Timed out waiting on input after ${timeout_in_sec}s\n"; } #### $plibMsg=&get_stdin_w_timeout(5);#;