aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYsmael Ebreo <Ysmael.Ebreo@latticesemi.com>2019-10-01 09:42:13 +0800
committerYsmael Ebreo <Ysmael.Ebreo@latticesemi.com>2019-10-01 09:42:13 +0800
commit91790bfbd333ea3ef1a363fd0c31f982f0c15de1 (patch)
tree8b25158961544aaf4a2f46f37ba99c5539530cd3
parentd92bcbed1a2535200e78b948aabb2905c3ab6fa6 (diff)
downloadperlweeklychallenge-club-91790bfbd333ea3ef1a363fd0c31f982f0c15de1.tar.gz
perlweeklychallenge-club-91790bfbd333ea3ef1a363fd0c31f982f0c15de1.tar.bz2
perlweeklychallenge-club-91790bfbd333ea3ef1a363fd0c31f982f0c15de1.zip
Simplified conditional statement and added comments for ch#28-2
-rw-r--r--challenge-028/yet-ebreo/perl5/ch-2.pl37
1 files changed, 23 insertions, 14 deletions
diff --git a/challenge-028/yet-ebreo/perl5/ch-2.pl b/challenge-028/yet-ebreo/perl5/ch-2.pl
index 0a21971e33..7babf706e3 100644
--- a/challenge-028/yet-ebreo/perl5/ch-2.pl
+++ b/challenge-028/yet-ebreo/perl5/ch-2.pl
@@ -4,8 +4,10 @@ use strict;
use warnings;
use v5.10;
+#Used to clear screen and to handle terminal screen commands
require Term::Screen::Uni;
my $scr = new Term::Screen::Uni;
+#Screen is cleared 1 time only
$scr->clrscr();
my @ascii_num= (
@@ -19,42 +21,49 @@ my @ascii_num= (
[" 777777 "," 77 "," 77 "," 77 "," 77 "],
[" 888888 "," 88 88 "," 888888 "," 88 88 "," 888888 "],
[" 999999 "," 99 99 "," 999999 "," 99 "," 999999 "],
- [" :: "," :: "," "," :: "," :: "],
+ [" "," :: "," "," :: "," "],
[" "," "," "," "," "]
);
my $toggler = 1;
while (1) {
+ #Get local time and store it in each variable
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();
+
+ #Convert to HH:MM:SS using sprintf
my $dig_time = (sprintf ("%02d:%02d:%02d", $hour,$min,$sec));
+
+ #Init lines to be printed
my @printline;
+ #For the blinking semicolon
$toggler = !$toggler;
for ($dig_time=~/./g) {
- if (/:/) {
- for my $i (0..4) {
- $printline[$i] .= $ascii_num[($toggler)?10:11][$i];
- }
- } else {
- for my $i (0..4) {
- $printline[$i] .= $ascii_num[$_][$i];
- }
+ for my $i (0..4) {
+ #Build up the text to be printed per line
+ $printline[$i] .= $ascii_num[/:/?($toggler)?10:11:$_][$i];
}
}
for my $i (0..4) {
+ #Select cursur at Row $i, Col 0
$scr->at($i,0);
+ #Print at selected Row/Col
print $printline[$i];
}
$scr->at(6,0);
print "Today is ".qw(Monday Tuesday Wednesday Thursday Friday Saturday Sunday)[$wday-1].": ".qw(January February March April May June July August September October November December)[$mon]." $mday, ".(1900+$year);
+
+ #Used as Delay, sleep only has 1 sec minimum delay
+ #But I need 500 ms for the blinking semicolon
select(undef, undef, undef, 0.5);
}
=begin
- 0000 0000 :: 555555 333333 :: 333333 333333
- 00 00 00 00 :: 55 33 :: 33 33
- 00 00 00 00 555555 333333 333333 333333
- 00 00 00 00 :: 55 33 :: 33 33
- 0000 0000 :: 555555 333333 :: 333333 333333
+perl .\ch-2.pl
+ 0000 999999 333333 44 44 222222 333333
+ 00 00 99 99 :: 33 44 44 :: 22 33
+ 00 00 999999 333333 444444 222222 333333
+ 00 00 99 :: 33 44 :: 22 33
+ 0000 999999 333333 44 222222 333333
Today is Tuesday: October 1, 2019
=cut \ No newline at end of file