in reply to How to UPDATE rather than append to STDOUT?
You could try using backspaces to back up over the previous number and overwrite it. Or use the ANSI cursor escape sequences to move back to the start of the line or directly to the position on the line and overwrite.
The following code is good Perl, but it does work.
#!e:\perl\bin\perl.exe -w use strict; use warnings; use diagnostics; for( my $n=1; $n<1000; $n++) { my $back = length $n; print $n, substr "\b\b\b\b", 0, $back; }
|
---|