rewrite a printed line

Discussion in 'Perl Misc' started by shay.rozen@gmail.com, Nov 12, 2006.

  1. Guest

    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".
    , Nov 12, 2006
    #1
    1. Advertising

  2. 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.
    Martijn Lievaart, Nov 12, 2006
    #2
    1. Advertising

  3. nic Guest

    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-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
    nic, Nov 12, 2006
    #3
  4. Joe Smith Guest

    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
    Joe Smith, Nov 13, 2006
    #4
  5. Guest

    Joe Smith wrote:
    > 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.
    , Nov 13, 2006
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John A Grandy

    height of printed line for a certain font size

    John A Grandy, Nov 4, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    476
    John A Grandy
    Nov 17, 2004
  2. =?Utf-8?B?c2FtZWVy?=

    printing to pre-printed page.

    =?Utf-8?B?c2FtZWVy?=, Jun 2, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    418
    =?Utf-8?B?c2FtZWVy?=
    Jun 2, 2005
  3. =?Utf-8?B?c2FtZWVy?=

    printing to pre-printed page.

    =?Utf-8?B?c2FtZWVy?=, Jun 8, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    405
    Oenone
    Jun 8, 2005
  4. Jay
    Replies:
    6
    Views:
    394
  5. Feng Tien
    Replies:
    4
    Views:
    109
    Dale Martenson
    Oct 24, 2007
Loading...

Share This Page