Time-limited input on STDINby ajdelore (Pilgrim)
|on Aug 08, 2003 at 22:02 UTC||Need Help??|
ajdelore has asked for the
wisdom of the Perl Monks concerning the following question:
I am trying to find a way to do time-limited input of a list of words. Basically:
This works OK. If I press enter after every word, once I am over the time limit it stops taking input. However, I do not want to rely on the user pressing enter.
What I think would work is to set $/ to whitespace. I tried using $/ = '\s'; with no luck -- \s is for regexes, IIRC.
Obviously, a user could sit in the middle of a word for as long as they want, but for my purposes that is OK. As long as whitespace is the separator, they can't cheat by entering 100 words on the same line before pressing enter.
Although, if monks have any ideas about how to stop input at 10 seconds regardless of wether the user was in the middle of a word or not, I'd love to hear them.