I am developing one console application using perl script. In that I am printing status of the process like “25 % Completed”, “33.33 % completed” etc… In that I am using \r for printing the statement in oneline. But, while execution the previous printed statement shadow also exist, which gives confusion. How to avoid that shadow of the previous printed statement. Example code has been written below.
use strict;
$|=1;
my $length=7;
my $progress_limit=100/$length;
my $progress;
for(my $i=1;$i<=$length;$i++){
$progress=$progress_limit*$i;
print "Process completion status\: ".$progress." % Completed \r";
}
Thanks …
Use a fixed length string. sprintf formatting is a great way to achieve that.