continous update (print)

L

Lars Madsen

if one e.g . wants to write a countdown one can do this as

$|=1;
....
# some loop
printf "% 4d\r", $count;

where \r then makes sure that we reprint on them same line over and over again.

But what if you want to do this with several lines at once?

I have a data structure with, say, 10 special entries that changes every second,
I would like to have a continous overview if these numbers in the same fashion
as above.

How would one do that?
 
L

Lars Madsen

A simple solution is to clear the screen before printing:

my $clear = qx(clear);

while ( 1 ){
print $clear;
printf "%s\n",'some text';
}

well yes, besides the fact that the screen flickers a bit, clearing the screen
seems to work.
 
A

anno4000

Aukjan van Belkum said:
Yes it does ... i didn't say it was pretty ... just simple ;-)

Put a delay in the loop and update the screen only once per second or so.
The flicker will get much bettter.

Anno
 
L

Lars Madsen

es it does ... i didn't say it was pretty ... just simple ;-)
Put a delay in the loop and update the screen only once per second or so.
The flicker will get much bettter.

Anno

I already do that, it looks ok.
 
J

Jürgen Exner

Lars said:
if one e.g . wants to write a countdown one can do this as

$|=1;
...
# some loop
printf "% 4d\r", $count;

where \r then makes sure that we reprint on them same line over and
over again.
But what if you want to do this with several lines at once?

I have a data structure with, say, 10 special entries that changes
every second, I would like to have a continous overview if these
numbers in the same fashion as above.

How would one do that?

Use the Curses module to position the cursor before each output block.

jue
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top