#!/usr/bin/perl -w
pipe(FROM_CHILD, TO_PARENT);
$pid = fork();
if ($pid == 0) {
# We're in the child process.
close(FROM_CHILD);
# Send data to parent.
print TO_PARENT "Hello, parent\n";
exit(0); # Terminate child.
} elsif (undef $pid) {
print "Not defined: means an error.";
} else {
# Parent process.
close(TO_PARENT);
$data = ;
print "From child: $data\n";
$id = wait();
print "Child $id is dead.\n";
}