I am trying to read unbufferd data from a pipe in Perl. For example, in the following program:
open FILE,"-|","iostat -dx 10 5"; $old=select FILE; $|=1; select $old; $|=1; foreach $i (<FILE>) { print "GOT: $i\n"; }
iostat provides data every 10 seconds (five times). You would expect this program to do the same. However, instead, it seems to hang for 50 seconds (i.e. 10x5), after which it spits out all the data.
How can I get to return all available data (in an unbuffered way) without waiting for the EOF to complete?
PS I have seen numerous links to this under Windows - I do this under Linux.
Brad
source share