in reply to select?

Being asked by BooK, I assumed this was for obfuscation.

select("\01","","",10);
should wait for any character on STDIN [but this won't work under Win32, for example, because select() there only works on sockets]. However, this only works for a Unix TTY if the TTY is not in "line mode". So I don't think this will help you much, BooK.

        - tye (but my friends call me "Tye")

Replies are listed 'Best First'.
Re: (tye)Re: select?
by BooK (Curate) on Dec 27, 2000 at 23:29 UTC

    Thanks, at least I know why it doesn't work on my Win32 box at work... :-)

    As for line mode, wouldn't $| help? (mmm, doesn't look like it) Well, if this doesn't work, it seems there are still other options...

    PS: Tye, there are two me, really: I do actually write readable, useful code. It's just not as fun...

      No, $| controls auto-flushing of output which is often confused with buffering (which can be "none", "line", or "block" in Unix) but doesn't have much to do with input.

      To see characters from a Unix TTY before a newline, you need to get into "raw" or "semi cooked" mode instead of the usually "cooked" mode. "raw" means no processing is done and "semi cooked" means much (but not all of the usual) processing is done but you get characters as they are typed (though I still think there is a timer involved here so you usually don't even get them immediately, just almost immediately -- it has been too long since I had the misfortune to care about this stuff).

      I have yet to find a good way to read one character at a time in Win32, much less a module that portably handles this.

              - tye (but my friends call me "Tye")