On win32/cygwin, how to determine whether fd (stdin) has input?
David> like to read from stdin, but only if there is input present. ) From
David> reading the FAQs, I get the impression that the ) Term::ReadKey
David> package would be useful for this, but I find that ) I cannot build it
David> on win32/cygwin.
David> ) I also tried the "select" solution (the first suggestion in the )
David> "How can I tell if there's a character waiting on a filehandle?" )
David> question), but that seems to always return "-1", whether there ) is
David> really input available or not.
Tye> select() on Win32 is only a "WinSock" call and so only works on
Tye> sockets, which STDIN is _not_ likely to be.
Tye> On Win32, you could use Win32::Console, but that doesn't come with
Tye> cygwin perl. I haven't tried to build it under cygwin, so you might
Tye> want to try it -- it might actually work.
Tye> You could post the errors you got trying to build Term::ReadKey under
Tye> cygwin in hopes that those are problems that can be overcome.
I've actually gotten through building ReadKey. I was missing a path entry, and
I was missing the "cygipc" package.
However, I now have a problem based on my misinterpretation of what "ReadKey"
does. Of course it reads and consumes a key, but I need to only determine
whether input is present. Is there an easy way to make it nondestructively
read? I didn't see anything obvious in the ReadKey man page. Alternatively,
is it feasible/possible to "ungetc" the character to the file descriptor?