http://qs1969.pair.com?node_id=45155


in reply to Re: Re: Re: File copy progress.
in thread File copy progress.

Here is quick but cheap way to do it. Im just posting the progress routine but in the main routine you also have to toss the percent variable and instead have a variable keep track of total bytes writen. Then call this sub passing it total_writen, and file size. This routine also uses fastolfe's suggestion of using \r instead of \n so just the line is updated ( works on win2k too!).

sub FileProgress () { my $wrote = shift; my $size = shift; my $percent = $wrote / $size * 100; case: { if ($percent <11) { print "\r[* ]"; last;} if ($percent <21) { print "\r[** ]"; last;} if ($percent <31) { print "\r[*** ]"; last;} if ($percent <41) { print "\r[**** ]"; last;} if ($percent <51) { print "\r[***** ]"; last;} if ($percent <61) { print "\r[****** ]"; last;} if ($percent <71) { print "\r[******* ]"; last;} if ($percent <81) { print "\r[******** ]"; last;} if ($percent <91) { print "\r[********* ]"; last;} if ($percent <=100) { print "\r[**********]"; last;} } printf " %3u",$percent; print '%'; printf " done. %u bytes.",$wrote; return 1; }

zzSPECTREz