I'm not clear as to what you are trying to do. The \*WRITE ,\*READ, etc are the filehandles which let you send data to and from the program you are running thru IPC. They are pipes.You can name them anything you want, but their order is important.(Read perldoc IPC::Open3). If instead of \*ERROR, you put a 0 (i.e.false), then the stderr of the program gets sent to it's stdout, and will be combined in \*READ. If you want to know how to save the data to a file, you need another couple of filehandles, like:
....... open(OUT,">file_out) or warn "$!\n"; # then where you read the output print it to # the OUT filehandle #get the answer from bc sysread(READ,$answer,4096) if $selread->can_read(0); if($answer){print OUT "$query = $answer\n"} ($error,$answer)=('',''); }
If you want to read input from a file, you need to open that file, and read it line by line, and print each line to the WRITE handle, then wait for output. It sounds like you need to experiment with it a little bit. Here is a simpler version, without a separate stderr.
#!/usr/bin/perl use warnings; use strict; use IPC::Open3; #interface to "bc" calculator #my $pid = open3(\*WRITE, \*READ, \*ERROR,"bc"); my $pid = open3(\*WRITE, \*READ,0,"bc"); #if \*ERROR is false, STDERR is sent to STDOUT while(1){ print "Enter expression for bc, i.e. 2 + 2\n"; chomp(my $query = <STDIN>); #send query to bc print WRITE "$query\n"; select(undef,undef,undef,2); #get the answer from bc chomp(my $answer = <READ>); print "$query = $answer\n"; } waitpid($pid, 1); # It is important to waitpid on your child process, # otherwise zombies could be created.

I'm not really a human, but I play one on earth. flash japh

In reply to Re^3: example for ipc::open3 by zentara
in thread example for ipc::open3 by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.