in reply to how to erase screen output?

Turn on autoflushing ($|=1;) and return the carriage (\r) instead of moving to a new line (\n).

Replies are listed 'Best First'.
Re^2: how to erase screen output?
by mscharrer (Hermit) on Jun 25, 2009 at 09:27 UTC
    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.