- my $n = (_POSIX_PIPE_BUF / UINT_SIZE);
- if ($n >= $#todo) {
- print $wr join('', map { pack('I', $_) } (0..$#todo)) or DIE;
- undef $wr;
- } else { # write what we can...
- $wr->autoflush(1);
- print $wr join('', map { pack('I', $_) } (0..$n)) or DIE;
- $n += 1; # and send more ($n..$#todo), later
- }
+ $wr->autoflush(1);
+ $wr->blocking(0);
+ my $todo_buf = join('', map { pack('I', $_) } (0..$#todo));
+ my $woff = syswrite($wr, $todo_buf) // DIE "syswrite: $!";
+ substr($todo_buf, 0, $woff, '');