#! perl -slw use strict; use threads; use threads::shared; my $outfile = 'output.txt'; unlink $outfile ; my $done:shared = 0; async{ system("dir /s > $outfile"); $done =1; }; sleep 1 until -e $outfile; printf STDERR "\r%d\t", -s( $outfile ) and sleep 1 until $done; print STDERR 'Output complete';