Use my $status = $?>>8
From your code, I could not tell how yoy were running MAKE (you were onlyprocessing items in the make file). So Assuming you were running "make -f my_makefile".
Then this should do it.
#!/opt/local/bin/perl $foo=`make -f my_makefile`; #you could replace line with system("make -f my_makefile") my $status = $?>>8; print "\n\n fo status = $status\n\n";
I can't use backticks to call 'make' in this case. I need to process the input as it comes in. This program will act as a 'make' wrapper. It will display a percent completed instead of the normal 'make' output. In the case of an error exit, I want it to print @buffer which will contain the last 15 lines of 'make' output.
#!/usr/bin/perl
use strict; use warnings;
$| = 1; my $count = 0; my $makeargs = join ' ', @_; #foreach (shift) { # $makeargs .= " $_"; #} my (@buffer, $line, $total, $makeout, @makedirs); my $onedir = 1; my $dirpos = 0; $makeout = `make -n ${makeargs}`; if($makeout =~ /^make\[\d+\]: Entering/m) { $onedir = 0; while($makeout =~ /^make\[\d+\]: Leaving directory `(.+)'$/cgm) { push @makedirs, $1; } } if($onedir) { $total = `echo ${makeout} | wc -l`; } open MAKE, "make ${makeargs} |" or die "Can't open MAKE pipe"; while (<MAKE>) { my $percent; $count++; $line = "$_"; if($#buffer < 14) { push @buffer, $line; } else { for(my $tmp=1;$tmp<15;$tmp++) { $buffer[($tmp-1)] = $buffer[$tmp]; } $buffer[14] = $line; } if($onedir) { $percent = int(($count / $total) * 100); } else { chomp($line); if($line =~ /^make\[\d+\]: Leaving directory `$makedirs[$dirpos]'$/) { $dirpos++; } $percent = int(($dirpos / ($#makedirs + 1)) * 100); } print "\r${percent}% "; } print "\n";
In my case, could I add this code at the end to do what I want?
if($?>>8) { # return code is non-zero print "A compilation error occured. Last 15 lines of output follow:\n"; foreach (@buffer) { print "$_\n"; } }
-- Andrew Gaffney Network Administrator Skyline Aeronautics, LLC. 636-357-1548
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>