Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Sending open file contents through an external program

by hippo (Bishop)
on Aug 21, 2018 at 21:22 UTC ( [id://1220806]=note: print w/replies, xml ) Need Help??


in reply to Sending open file contents through an external program

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

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1220806]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-03-29 06:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found