As far as making the clock update exactly every second, I would probabaly just insert a
sleep 1 in the program and call it close enough. In order to make the clock increment exactly on the second, you'd have to figure out how long the code took then sleep for 1 second minus that time. That just seems like too much work to me.
As for updating the clock, why not just clear the screen and redraw it? The Perl Cookbook suggests doing
$clock = `clear`; and then just
print $clear; whenever you want to clear the screen. It also provides a longer way, although its advantage isn't clear to me at this moment:
use Term::Cap;
$OSPEED = 9600;
eval {
require POSIX;
my $termios = POSIX::Termios->new();
$termios->getattr;
$OSPEED = $termios->getospeed;
};
$terminal = Term::Cap->Tgetent({OSPEED=>$OSPEED});
$terminal->Tputs('cl', 1, STDOUT);
For some general framework, look at what I did here:
$clear = `clear`;
while (1){
print $clear;
$time = localtime();
print "$time\n";
sleep 1;
$l++;
}
It provides a fairly smoothly incrementing clock. You should be able to do something similar with the more complex output you're talking about. Notice how I'm just clearing the screen and redrawing the clock each time?
And finally, as far as using blocks, why not just use extended ASCII code 219, which is a block character, in place of the asterisks? Hope this helps!
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.