I would put the '\r' at the beginning not the end of the line:
print "\r$_/5" foreach (1..5);
# and then:
print "\n"; # or print ' 'x10, "\n";
This places the cursor at the end of the line not at the start. In this small example this does not make any difference but if the loop takes a second or so to process the cursor will be visible. Also following lines would overwrite the last line otherwise, which is not always wanted.
|