ybnormal has asked for the wisdom of the Perl Monks concerning the following question:
Now this program needs to monitor the key event and if 's' key is pressed, it changes the message to, say "somebody, start me". Afterwards, everytime 's' key is pressed, it pingpongs the message. The question is how I can detect the key input while the program is printing out the message in the infinite loop. I read some thread saying ReadKey can do it, but not sure how I can do it in this scenario. Appreciate your suggestion.#!/usr/bin/perl while(1){ print "Somebody, stop me..\n"; sleep(1); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: detecting the keystroke.
by almut (Canon) on Apr 28, 2010 at 06:48 UTC | |
by ybnormal (Novice) on Apr 28, 2010 at 06:59 UTC |