Perl Term::ReadKey don't wait for newline

Posted by tim on Stack Overflow See other posts from Stack Overflow or by tim
Published on 2010-06-16T15:30:16Z Indexed on 2010/06/16 15:32 UTC
Read the original article Hit count: 144

Filed under:

In a perl script, I'm trying to accept input without blocking and without echoing the characters entered (The script is producing output and I want to have 'hotkeys' to alter its behaviour).

I got as far as using

use Term::ReadKey;
ReadMode( "cbreak", STDIN );
if($input = ReadKey($pause_time, STDIN)){
    #process input
}

But once the user types anything then the script stops until a newline is entered. I'd like the input to be processed per-character, without waiting for a newline.

© Stack Overflow or respective owner

Related posts about perl