my ($in, $out, $err) = (\*CHLD_IN, \*CHLD_OUT, \*CHLD_ERR); my $pid = open3($in, $out, $err, 'myprog -xyz blah') or die 'internal error'; print $in "some input\n"; close $in or die "$!: closing child STDIN\n"; my @out = <$out>; my @err = <$err>; close $out or die "$!: closing child STDOUT\n"; close $err or die "$!: closing child STDERR\n"; waitpid( $pid, 0 ); my $chexit = $?; print STDERR @err; chomp @err; @err and exit $chexit >> 8; # output from subprocess is in @out ...