Hi Matt

The \r option works fine, but an alternative is to use 'print "\b"' - this
will print a backspace character, and means you can have other stuff on the
line too. Try:
        $|=1; for ($i=0; $i<10; $i++) {print "$i\b";sleep 1}
This method only works for single digit numbers though, since it only
backspaces a single character (although you could set up a routine to
backspace more depending on the length of the output number). 

$| = 1 turns on OUTPUT_AUTOFLUSH so it prints each time through the loop,
rather than one big rush at the end. The sleep is just there so you have
time to see the number before the next loop.

Cheers

Mark C

>Hi Matt,
>
>I'm very new to perl (a week or so), so this may not be the best way to do
>this, but....
>
>for ($i=0; $i<10; $i++) {printf "%d\r",$i;}
>
>This will (should?) print the number followed by a Carriage Return (no
>linefeed), so the cursor returns to the start of the line.
>
>Hope this is what you wanted....
>
>Mark
>
>
>>I'm trying something like:
>>
>>for ($i=0; $i<10; $i++){print $i;}
>>
>>and have the numbers iterate in ONE PLACE at the cursor (i.e. print, 
>>then backspace,print the new number, etc). I'm having problems figuring
>>this out. Any ideas? 
>>
>>Thanks
>>
>>Matt

Reply via email to