Andrew Gaffney wrote:
I tried that and it still spits out all the output at the end. Here's my current code:
#!/usr/bin/perl
use strict; use warnings;
$| = 1; my $total = `make -n | wc -l`; print "$total\n"; my ($count, $line); open MAKE, "make |" or die "Can't open MAKE pipe"; foreach (<MAKE>) { $count++; my $percent = int(($count / $total) * 100); # print "${percent}..."; print $_; }
First of all, using foreach will _always_ wait for all of the data before doing anything else, no matter what, so first change:
foreach (<MAKE>) {
to:
while (<MAKE>) {
and then try to find out if maybe it is indeed being buffered, though $| won't help you here, as it sets autoflushing on output, not input.
Another thing is that "make" is probably going to print much more lines than "make -n" because "make -n" only prints the commands to be executed while those commands themselves are likely to produce some output as well, unless all of them are run with >/dev/null 2>&1 at the end.
What approach would you recommend?
-- 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>