Andrew Gaffney wrote:

open MAKE, "make |";
foreach $line (<MAKE>) {
$count++;
my $percent = int(($count / $total) * 100);
print "..$percent";
}

Try changing this line:


foreach $line (<MAKE>) {

to this:

while (defined($line = <MAKE>)) {

or if you can use $_ instead of $line, then just:

while (<MAKE>) {

which is really a short way of saying:

while (defined($_ = <MAKE>)) {

What you see here has nothing to do with buffering or flushing. When you use <MAKE> in the list context provided by foreach it first reads the whole file into a temporary array and then iterates through this array. When you use <MAKE> in a scalar context, e.g. with $line=<MAKE> or implicitly in while(<MAKE>), then only one line of the input at a time is being read.

See "I/O Operators" on perldoc perlop
http://www.perldoc.com/perl5.8.0/pod/perlop.html#I-O-Operators

Is that what you were looking for?

--
ZSDC


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to