in reply to Sending open file contents through an external program

Have you considered IPC::Open3 and/or IPC::Run?

  • Comment on Re: Sending open file contents through an external program

Replies are listed 'Best First'.
Re^2: Sending open file contents through an external program
by TheloniusMonk (Sexton) on Aug 22, 2018 at 07:18 UTC
    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 ...
      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.
Re^2: Sending open file contents through an external program
by pdac (Novice) on Aug 21, 2018 at 23:17 UTC

    I had not (didn't know about them). They certainly look interesting - I will check them out tomorrow.

    Many thanks for the steer.