A version that does the timeout as well:
use warnings; use strict; use Term::ReadKey; my $key; my $start = time (); local $| = 1; print "Press a key: "; while (not defined ($key = ReadKey(-1))) { last if time () - $start > 10; } print defined $key ? "\nGot key $key\n" : " No key after 10 seconds";
In reply to Re: Timed wait for input
by GrandFather
in thread Timed wait for input
by dominic7
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |