i have script gets executed, require loop tells process sleep 20-30 secs whilst user runs different test.
once test completed user presses enter continue script halted. if enter not pressed within 20-30 second period script continue run without user input.
i tried following code pauses script indefinitely – not continue after 20 secs, not accept enter.
use term::readkey; readmode 4; { sleep 20; } until ( defined( $key = readkey(-1) ) ); readmode 0;
try while
loop instead of do{}
#!usr/bin/perl use strict; use warnings; use term::readkey; readmode 4; # turn off controls keys $key; while ( !defined( $key = readkey(-1) ) ) { print "no key yet\n"; sleep 5; } print "get key $key\n"; readmode 0; # reset tty mode before exiting
Comments
Post a Comment