rewrite a printed line

S

shay.rozen

I have a script which output some icmp results. I print the results
line by line till the list of hosts reaches the end, and then its
repeats from the start by deleting the output screen (I use windows
"cls").
My question is can i go up my output on the screen, like print a line,
and then go with the "curser" back to this line and rewrite it by
another print. Something like "old line" instead of "new line".
 
M

Martijn Lievaart

I have a script which output some icmp results. I print the results
line by line till the list of hosts reaches the end, and then its
repeats from the start by deleting the output screen (I use windows
"cls").
My question is can i go up my output on the screen, like print a line,
and then go with the "curser" back to this line and rewrite it by
another print. Something like "old line" instead of "new line".

Try printing a '\r' instead of a '\n'. Works on most OSses/terminals. (As
long as you don't print more than one screen line per line). Remember to
print extra spaces to completely erase the previous line.

M4
 
N

nic

I have a script which output some icmp results. I print the results
line by line till the list of hosts reaches the end, and then its
repeats from the start by deleting the output screen (I use windows
"cls").
My question is can i go up my output on the screen, like print a line,
and then go with the "curser" back to this line and rewrite it by
another print. Something like "old line" instead of "new line".

Look at something like Term::Screen
(http://search.cpan.org/~jstowe/Term-Screen-1.03/Screen.pm)

The "at" method give you control (based on row and column) as to where on
the screen you want to print.

Just remember to delete the existing line first ("clreol" method).

I just don't know how well it works in a Windows command box :(

Cheers
 
J

Joe Smith

My question is can i go up my output on the screen, like print a line,
and then go with the "curser" back to this line and rewrite it by
another print.

I use this statement in the middle of a loop:

print "Estimated $total in $count files\r" if ++$count % 1000 == 0;

-Joe
 
S

shay.rozen

Joe said:
I use this statement in the middle of a loop:

print "Estimated $total in $count files\r" if ++$count % 1000 == 0;

-Joe

I've tried \r. It doesn't work on windows. I tried Term::Screen:Win32
and perl.exe got stuck when trying to run the module. Funny, but this
is the first time i'm scripting perl for windows and so much troubles.
Anyway thank you all for the fast reply. I believe your solutions are
great, but bill think the other way around.
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top