You need to clear the input buffer before reading the next response.
Maybe this module does already cover all your requirements? IO::Prompter or Term:UI
Update: The following method clears the input buffer (at least on Unix):
use Term::ReadKey; sub flush_stdin { ReadMode 4; ReadLine(-1); ReadMode 0; } sleep 5; # type 'something' flush_stdin(); $|=1; print "---> "; chomp (my $answ = <STDIN>); print "answ: ($answ)\n"; # w/o 'something'
Update: Cannot test it under Windows, but maybe Win32::Console works (see Flush() method)?
In reply to Re: Disabling keyboard input
by Perlbotics
in thread Disabling keyboard input
by hegotf
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |