while ($time > 0) { print " " . ' ' x (3 - length($time)) . "$time $line"; foreach (1..$backcount){print "\b"} $time -= 1; sleep 1; } #### while ($time--) { printf(" %3s %s", $time, $line); print "\b" for (1..$backcount); # or this could even be written as: # print "\b" x $backcount; sleep 1; }