use IO::Handle; use strict; use warnings; $| ++; pipe(GRANDPARENT_RDR, PARENT_WTR); if (fork()) { close PARENT_WTR; while (my $line = ) { print "grand parent got $line"; } } else { close GRANDPARENT_RDR; pipe(PARENT_RDR, CHILD_WTR); if (fork()) { close CHILD_WTR; while (my $line = ) { print "parent got $line"; print PARENT_WTR $line; } } else { close PARENT_RDR; for (0..10) { print CHILD_WTR "$_\n"; } } }