in reply to Re: Sending open file contents through an external program
in thread Sending open file contents through an external program

Example:
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 ...

Replies are listed 'Best First'.
Re^3: Sending open file contents through an external program
by pdac (Novice) on Aug 22, 2018 at 21:08 UTC
    As it turned out, for various reasons, I had to create an intermediate file anyway. But this example is just what I was after - many thanks, I will surely have use for it sometime soon.