for( my $i = 1; $i <= 10; $i++ ) { last unless $out; print "Calling sysread; "; my $bytes = sysread($out, $buffer, 4096); print "Try #$i: $bytes Bytes read.\n"; last unless $bytes; print "$buffer\n\n"; }