If you know in advance what character data you're going to feed to the program after it starts running, and you don't need to capture its output to a variable inside your perl script, a pipeline open would be easiest:
open( PIPE, "| comparepass.exe" ); print PIPE "some_file.name\n"; close PIPE;
Of course, since the child process does generate output, this might cause some trouble if you don't redirect it somewhere -- just add " > junkfile.name" after the name of the program in the open statement. (This might not be a bad be a good idea if you want your script to read the program's output after it runs.)

<update> if you really are running the program on a unix system, and you really don't need the stuff that the program spits out, redirect like this:  &> /dev/null (that will send both stdout and stderr to the bitbucket). </update>

If you know you need to capture the output from the program for use in your script, the next easiest thing to try is IPC::Open2. With that, you get two file handles, one to send input to the program, and the other to read its output.

If you don't know what input you'll give to the program until you get its initial "menu" output, and the program was written in such a way that its output ends up being buffered when its stdout is not a terminal, then you'll need to use expect.


In reply to Re: Interacting with a child process by graff
in thread Interacting with a child process by K_M_McMahon

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.