in reply to percentage while loop

In case the files you have to process are quite large, I recommend to limit the number of updates of your progress indicator. Maybe 10-100 updates per prcessed file are sufficient? The following snipped will update about 100 times:
#in the loop # update $percentage, e.g. 100 * $summed_size / $file_size; ... (printf STDERR "Progress: %3d%%\r", $percentage),$lastpercentage=int($ +percentage) if int($percentage) != $lastpercentage; ...
Last given output might not be '100%'. You might want to force an update at the last iteration (using e.g. eof).