open $old_stdout, ">&STDOUT" or die "open: $!"; local(*RH, *WH); pipe RH, WH; open STDOUT, ">&WH" or die "open: $!"; # write something to the pipe print "foo"; # and have some fork/exec'ed process write to the pipe (via stdout) system('echo bar'); close WH; my $out = ; print STDERR "got from pipe: $out"; # $out is "foobar\n"