David Le Blanc wrote: > > > From: John W. Krahn [mailto:[EMAIL PROTECTED] > > > > Andrew Gaffney wrote: > > > > > > Is there a way to get an external process's output *and* > > return value? I have a program > > > that opens a pipe to 'make', process all the input, and > > then checks the return value when > > > the loop ends (pipe is broken/closed): > > > > > > open MAKE, "make |" or die "Can't open MAKE pipe"; > > > > > > while(<MAKE>) { > > > # Process input > > > } > > > if($make_return_value) { > > > # An error occured with 'make' > > > } > > > > > > How do I get that return value? > > > > perldoc -f open > > [snip] > > Closing any piped filehandle causes the parent > > process to wait for the child to finish, and > > returns the status value in `$?'. > > if( open(MAKE, "make |" ) ) { > while (<MAKE>) { > $rant; > } > $rc = close( MAKE ); > } else { > print "Can't make..".$/; > $rc = -1; > } > > print "Completed with rc=$rc".$/;
And how does that get make's return value? John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
