http://qs1969.pair.com?node_id=758561


in reply to Non-blocking reading on STDIN?

I want to create a non-blocking read on STDIN, that means I don't have to enter RETRUN, each characters would show up just after I have enter it on the terminal

I think you mean RETURN. Anyway, the two things you mention are not the same. Blocking mode means that read operations blocks until input is available. Input is available if you have typed either a character or a whole line, depending on the terminal settings. This particular setting is known as "canonical mode". You can test it with the "stty" command, but undoubtedly there CPAN modules to leave and enter canonical mode.

Another thing one should be aware about: For terminal applications, usually STDIN has the same file descriptor as STDOUT. This means that if you set the non-blocking flag for STDIN, it will be set for STDOUT, too. This means that if you print a long buffer to the terminal, it might be truncated and print returns EAGAIN. But as nobody checks the error code when printing to a terminal (e.g. curses doesn't seem to do so), the terminal will at some point display unexpected contents.