From: Michael Alipio > > Is it possible to print something and then replace what you > have printed with a different value? > > Say I have a program that watches a logfile and prints the > current number of lines. > > after sleeping for n seconds, it will print the number of > lines again. But i don't want to print it below the old output. > I want to replace it with the new output.
I believe the technique used will depend on your terminal definition. In some cases a CR will return the cursor to the start of the line, then you can print over the previous text. This was often done on printers or teletypes for ASCII pictures in the olden days. This may cause problems on a video display if the new text is shorter than the old, but in this case that is not likely. If your display won't work this way, you will need to send a series of backspaces to erase the old line and then print the new one. I have even seen code that used backspace-space-backspace to erase each character as the cursor moved back through the line. Bob McConnell -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/