redss has asked for the wisdom of the Perl Monks concerning the following question:
Hello monks!
My program needs to process data and periodically poll for keyboard input.
What function can I use on the third line to check if a key was pressed, without waiting forever for input?
while (1) { sleep(1); if key was pressed { # HELP, how can I check? print "$key was pressed\n"; exit if $key eq 'q'; } do stuff... }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: how to check for keyboard input
by Tanktalus (Canon) on Jul 21, 2005 at 04:14 UTC | |
Re: how to check for keyboard input
by tlm (Prior) on Jul 21, 2005 at 04:15 UTC | |
by Tanktalus (Canon) on Jul 21, 2005 at 04:17 UTC | |
by chb (Deacon) on Jul 21, 2005 at 08:07 UTC | |
by benizi (Hermit) on Jul 21, 2005 at 17:17 UTC |
Back to
Seekers of Perl Wisdom