I am not sure how to put this question. I am trying to write a Perl program which invokes a child program (a Fortran program) so child program goes to stdin to get yes/no.
Is there a way Perl can give that option, wi开发者_JS百科thout letting child goes to STDIN?
Because of my poor programming vocabulary, I couldn't get an answer from Google.
You can start a progam with its input coming from a pipe like so:
open my $ftn_input, '|-', $fortran_program
or die "Couldn't start $fortran_program: $!";
if ($yes) {
print $ftn_input "Yes\n";
}
else {
print $ftn_input "No\n";
}
close($ftn_input) # waits for fortran program to complete
or die "Program failed; error $!, wait status $?\n";
精彩评论