Back to the program, the file.exe opens up like command prompt and in the folder where file.exe is, there is an input file "base.in". So, I need to open file.exe through perl and type in "base" in file.exe for it to take the input file and run.
(additional emphasis by me.)
I personally believe that the info you supplied is unfortunately still incomplete. It is enough to exclude that you have to use system because of that "to type in" - but whether a piped open is appropriate or not depends entirely on the method your file.exe uses to read what you type in. If it reads from STDIN then it's fine, and you only have to read the appropriate documentation linked to above: wrt the naive attempt you shown in the first post the main difference will be a the correct "mode" which is a simple string saying what to do with the filename. (Additionally, you used the two args form of open() in which the mode is attached to the filename itself, and I recommend as usual to use the three args one instead.) Specifically, you used ">" which means "write into" - and that's no good! Perl and the OS "know nothing" about the file itself to the effect that it is actually a program, and "write into" will literally do so, filling its contents with e.g. "base.in"; of course, this is not what you want, thus you have to explicitly tell it that it's a program and that you want to "write to it through STDIN." HTH: filling in the details is left as an easy exercise.
Incidentally, your original code also had open(-w EXECUTABLE,">$executable") and that looks very incorrect: it is, somewhat surprisingly, syntactically valid due to the existance of the -w function, but that -in turn- is nothing but a test that a given handle is readable, and does not belong there, by any means.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|