use strict; use IO::Pipe; use IO::Select; my $pipe = new IO::Pipe; if ( fork() ) { print "Parent live\n"; $pipe->reader(); my $ios = IO::Select->new(); $ios->add($pipe); while (1) { print "Handles: " . scalar $ios->handles . ", " . scalar $ios->can_read(1) . " ready.\n"; if ( $ios->can_read(1) ) { while (<$pipe>) { syswrite( STDOUT, "[r]", 3 ); print "[d:$_:d]\n"; } } else { syswrite( STDOUT, "[b]", 3 ); sleep 1; } } } else { print "Child live\n"; $pipe->writer(); $pipe->autoflush(1); while (1) { $pipe->print("HELLO!\n"); syswrite( STDOUT, "[W]", 3 ); sleep 1; } }