On 02/23/04 10:41, daniel wrote:
Hi Guys,

I'm running the following code under w2k command-line:

$| = 1; #Autoflush
print "Test\r";
sleep 2;
print "OK";

and the output is

OKst

Eh, how can I delete the whole privious print output ????

As you noticed the \r returns the "cursor" to the beginning of the current line; it does not affect the contents of that line.


There are two ways to do what you want. One is to pad the second string with spaces to overwrite the previous line. The other is to keep track of the strings you write so you can backspace to the beginning of the line:


$| = 1; #Autoflush


my $text = "Test";
print $text;
sleep 2;
print "\b" x length($text);
print "OK";


Randy.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to