Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > rewrite a printed line

Reply
Thread Tools

rewrite a printed line

 
 
shay.rozen@gmail.com
Guest
Posts: n/a
 
      11-12-2006
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".

 
Reply With Quote
 
 
 
 
Martijn Lievaart
Guest
Posts: n/a
 
      11-12-2006
On Sun, 12 Nov 2006 07:44:41 -0800, shay.rozen wrote:

> 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
--
Redundancy is a great way to introduce more single points of failure.

 
Reply With Quote
 
 
 
 
nic
Guest
Posts: n/a
 
      11-12-2006
On Sun, 12 Nov 2006 07:44:41 -0800, shay.rozen wrote:

> 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-...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

 
Reply With Quote
 
Joe Smith
Guest
Posts: n/a
 
      11-13-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:

> 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
 
Reply With Quote
 
shay.rozen@gmail.com
Guest
Posts: n/a
 
      11-13-2006

Joe Smith wrote:
> (E-Mail Removed) wrote:
>
> > 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


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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unit Testing, how to use assert_equal for last printed line? Feng Tien Ruby 4 10-24-2007 04:24 PM
How to read a text file line by line and remove some line kaushikshome C++ 4 09-10-2006 10:12 PM
height of printed line for a certain font size John A Grandy ASP .Net 2 11-17-2004 04:45 AM
Read a file line by line with a maximum number of characters per line Hugo Java 10 10-18-2004 11:42 AM
thin verticle white line appears on printed picture Brian Digital Photography 6 10-11-2004 02:31 AM



Advertisments