use IO::Pipe; use strict; my $pipe = IO::Pipe->new(); if(my $pid = fork()){ waitpid($pid, 0); $pipe->reader(); my $str = <$pipe>; print "\$str == '$str'\n"; }else{ $pipe->writer(); &print_to_pipe($pipe); } sub print_to_pipe { my $fh = shift; print $fh "Hello World\n"; }