pipe $reader, $writer; $reader->blocking(0); ... if (fileno($fh) == fileno($reader)) { read $reader, my $line, 1e5; $output .= $line; } ...