Hello. I am self teaching perl and I have come to a road block, because I do not understand if what I want to do is fundamentaly possible in perl. I would like to have a running clock on a screen while it waits for user input. But I want the clock to be at a certain place in the screen, not just where the user would enter data. So far my understanding of programming is "line by line", so I do not understand how to tell perl to do Routine A while also doing Routine B. I came up with this script that kind of gives idea of what I want, obviously its not perfect because it runs in infinite loop, but you can get an idea of my thinking so far.
#!/usr/bin/perl #The \033[ stuff only works in Xterm print ("\033[2J"); #<- Clears screen print ("\033[6;0H"); #<- Repositions cursor at 6 down 0 from the left print ("Press C to continue\n"); print ("Press Q to quite\n"); do{ print ("\033[s"); #<-- Saves Cursor Position print ("\033[3;6H",`date`); #<-- Puts date and time above "Press C + to continue" print ("\033[u"); #<-- Restores Cursor Position }until (exists $input[0]); if ( $input eq Q ){ exit; }
Here is what I'm looking for as far as layout
May 21 22:00 Press C to continue Press Q to quite
Other then not knowing how to get $input entered, this sort of does what I want, except that you can tell that its drawing the screen over and over because the cursor moves back and forth.

Is it within perl's capabilities to draw the clock at the top of the screen, but also wait for user input below the choices?

In reply to Can I have a running clock within a script in Xterm? by westrock2000

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.