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 `$?'.
close MAKE or do {
$make_return_value = $? >> 8;
die "Error: make returned $make_return_value\n$!";
};
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>