my ($block_size) = 10_000_000; # 10MB block size my ($timeout) = 0; # Don't wait. my ($rfd) = ''; # Initialize with string only # SYNOPSIS: open ($filehandle, "FILE or PIPE"); CheckHandle ($filehandle); sub CheckHandle { my ($filehandle) = @_; vec ($rfd, fileno($filehandle), 1) = 1; # Wait for something to happen, and make sure # that it happened to the right filehandle. if (select ($rfd, undef, undef, $timeout) >= 0 && vec($rfd, fileno($filehandle), 1)) { # Something came in! my ($buffer); read ($filehandle, $buffer, $block_size); return $buffer; } return; }