in reply to How to tell if a pipe opened for reading has data to be read

Perhaps you might benefit from having a look at the answers from the last time this question was asked:

- Non blocking read on a filehandle

One example that was reported to work was the one about halfway down using Fcntl. Only worked on UNIX though, which doesn't seem like it will be a hindrance for you.

Although setting select's timeout to 0 doesn't work, you could set a minimal timeout like 0.01 (1 ms) which might work in your current implementation scheme, but is still inelegant.
  • Comment on Re: How to tell if a pipe opened for reading has data to be read

Replies are listed 'Best First'.
Re^2: How to tell if a pipe opened for reading has data to be read
by dk (Chaplain) on Mar 30, 2007 at 13:10 UTC
    Hm. Why does setting select's timeout to 0 not work? It should work, at least in POSIX-compatible implementations.
      I was hoping that Perl would turn an 'undef' for $timeout into a NULL pointer and '0' for $timeout into a struct timeval with a 0 value, but I hadn't tested it. One of the comments in the earlier thread Re: Re: Non blocking read on a filehandle indicated it wasn't working then (back in 2001).