Kian-Meng Ang Weekly Review: Challenge - 028

Sunday, Oct 13, 2019| Tags: Perl

Continues from previous week.

Feel free to submit a merge request or open a ticket if you found any issues with this post. We highly appreciate and welcome your feedback.

For a quick overview, go through the original tasks and recap of the weekly challenge.


Task #1


CPAN modules used: Const::Fast, Cwd, File::Basename, File::MMagic, File::Type, Function::Parameters, Modern::Perl, Moose, Test::More, constant, feature, strict, utf8, warnings

We would recommend that you start with the solution by Duncan C White, Colin Crain and Joelle Maslak for their intriguing and well-written comments.

The common approach found in most submissions was to use the file test operator in Perl, where -B and -T was used to determine whether a file is a text or binary file.

Participants not using this approach were Veesh Goldman, Adam Russell, Ruben Westerberg, Duncan C. White, Feng Chang, Steven Wilson and Joelle Maslak.


Task #2


CPAN modules used: Acme::Cow, Carp, Const::Fast, Data::Dumper, Date::Manip, DateTime, DateTime::Set, English, Function::Parameters, Getopt::Std, Imager, Modern::Perl, POE, POSIX, SVG, Term::ANSIColor, Term::ANSIScreen, Term::ReadKey, Term::Screen::Uni, Text::Banner, Tie::IxHash, Time::HiRes, Time::Piece, Tk, boolean, feature, sigtrap, strict, utf8, warnings

This was probably the only task where so many CPAN modules was used to solve this problem. And it seemed most participant were having a fun time building seven-segment LED display clock. Participants who took this approach were Duane Powell, Dave Jacoby (non-ticking), Prajith P, Roger Bell_West (non-ticking), Yet Ebreo, Pete Houston, Steven Wilson (non-ticking), Andrezgz, Colin Crain (non-ticking) and Julien Fiegehenn.

Of course, there were participants like Dave Cross, Athanasius, Lars Thegler, Ruben Westerberg, Kivanc Yazan, Feng Chang, Laurent Rosenfeld and Joelle Maslak (non-ticking) who decided to solve this task using the bare minimum approach. Just display the digital clock as it is using the default text at the console. While the output was the same, different participant used different approach to refresh the digital clock as shown in table below.

| Action                      | Dave Cross            | Laurent Rosenfeld | Kivanc Yazan            |
|-----------------------------|-----------------------|-------------------|-------------------------|
| Move cursor to first column | "\b\b\b\b\b\b\b\b"    | "\r"              | $console->Cursor(0, 0); |
| Autoflush the output        | STDOUT->autoflush(1); | $\|++             | cls();                  |

A few things that caught our attention that deserved mentioned on its own.

Adam Russell demonstrated that you can write a digital clock using event driven approach through POE CPAN module.

Julien Fiegehenn‘s submission was well-coded and adequately explained on why he did things in a certain manner, especially on the generation of the alphabet. Likewise for Yet Ebreo and Andrezgz. Julien was also the only participant that attached a cpanfile file, which in our opinion, a nice touch to install all CPAN modules in one shot.

Both Duncan C. White and E. Choroba were the only participants whose solutions used the Tk toolkit. And the later solution was the only submission where you can adjust refresh rate of the clock ticking.

If you don’t want to generate your own segment display, use the Text::Banner CPAN module as seen in the solution by Pete Houston.

The most amusing solution came from Lubos Kolouch. Embrace the talking barnyard animals.


SEE ALSO


(1) Perl 6 Binary Clock by Arne Sommer

(2) Perl Weekly Challenge 028 by Adam Russell

(3) Fake Seven-Segment Displays with Perl and SVG by Dave Jacoby

(4) Perl Weekly Challenge 28: File Type and Digital Clock by Laurent Rosenfeld

(5) RogerBW’s Blog: Perl Weekly Challenge 28 by Roger Bell_West

(6) Perl Weekly Challenge 028: File Content and Digital Clock by E. Choroba

SO WHAT DO YOU THINK ?

If you have any suggestions or ideas then please do share with us.

Contact with me