in reply to Refresh display in Perl

perl -e 'system("who"),sleep 10 while 1'
or
perl -e 'system("who"),sleep 10,system("clear") while 1'
to clear the screen between who invocations.

-sauoq
"My two cents aren't worth a dime.";

Replies are listed 'Best First'.
Re: Re: Refresh display in Perl
by choocroot (Friar) on Jul 30, 2003 at 19:22 UTC
    Instead of launching the 'clear' command everytime you can also store the clear sequence in a variable then just print it:
    perl -e '$clear=`clear`; system("who"),sleep 10,print $clear while 1'

      Uh... Yes... But that makes your one-liner longer and saving the overhead of calling clear really isn't worth it.

      -sauoq
      "My two cents aren't worth a dime.";
      

        Or... skip the system call altogether and use some ascii escape codes :) Assuming you're using a terminal that supports it:

        perl -le 'print "\e[2J\e[H", `who` and sleep 2 while 1'


        If the above content is missing any vital points or you feel that any of the information is misleading, incorrect or irrelevant, please feel free to downvote the post. At the same time, please reply to this node or /msg me to inform me as to what is wrong with the post, so that I may update the node to the best of my ability.