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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Re: File copy progress.
by Kanji (Parson) on Dec 06, 2000 at 07:03 UTC | |
by zzspectrez (Hermit) on Dec 06, 2000 at 10:41 UTC | |
by bcole23 (Scribe) on Jan 23, 2006 at 18:55 UTC |