use strict; use warnings; use IO::Socket; my $handle; my $pid; if (!defined($pid = open($handle, "|-"))) { die "Fork failed: ".$!; } elsif ($pid == 0) { # Child sleep(5); exit 0; } else { # Parent $handle->autoflush(1); my $i = 0; my $result; do { $result = print $handle "ABC\n"; print "PIPE write ".++$i."\n"; } while ($result); }