Consider the following script:
use IO::File;
$| = 1;
my ($handle, $pid) = myPipe();
if ($pid == 0) {
print \"$$\";
sleep 5;
exit;
}
print \"child: \".
On some (most?) systems, pipes use I/O buffering by default. Put a
$handle->autoflush(1);
statement in your myPipe function.
But even when buffering is turned off, Perl still doesn't flush except after a newline. So you may also want your child process to include a newline in the output.
Update: Testing your code (Cygwin, perl 5.10.0, YMMV), I see the issue is a lack of the newline in the child output, not whether autoflush is explicitly turned on when the pipe is created.