Quote:
> So I am trying to do something like this:
> open COMMAND, "make -f Makefile |";
> while(<COMMAND>)
> {
> print;
> }
> close COMMAND;
> But now I need to check the return value of 'make.' I need to know
> if it was successful or if it failed. But I don't know how to do
> this. I tried combinations of '$?' but that doesn't seem to work.
> Ideas? Thanks.
> -j
Easier to use system.
system("/usr/bin/make -f ./Makefile") == 0 or die "make failed!";
If you need the error, you could capture STDERR.
From perlfaq8:
To capture a command's STDERR but discard its STDOUT:
$output = `cmd 2>&1 1>/dev/null`; # either with backticks
$pid = open(PH, "cmd 2>&1 1>/dev/null |"); # or with an open pipe
while (<PH>) { } # plus a read