in reply to Non blocking read on a filehandle

If you are on Win32, you are just out of luck. But if you are on unix/linux you can set the filehandle to non-blocking. This will let you read from the handle if something is there. If nothing is there it will continue on to the next line of code.
use Fcntl; my $flags; fcntl(FILEHANDLE, F_GETFL, $flags) || die $!; # Get the current flags +on the filehandle $flags |= O_NONBLOCK; # Add non-blocking to the flags fcntl(FILEHANDLE, F_SETFL, $flags) || die $!; # Set the flags on the f +ilehandle

Replies are listed 'Best First'.
Re: Re: Non blocking read on a filehandle
by odie (Sexton) on Jan 30, 2001 at 19:55 UTC
    This seems to work. (so far =)
    It is also quite nifty. I like it.

    --
    I am a manual signature virus. Copy me please!
Re^2: Non blocking read on a filehandle
by Anonymous Monk on Jan 08, 2009 at 16:08 UTC
    my $flags = 0; works for me