aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2019-10-02 11:42:06 +0100
committerGitHub <noreply@github.com>2019-10-02 11:42:06 +0100
commit5cc1758323aeb82060065a7fe214bf4c6184f1e4 (patch)
tree355f8bc09b7bf5d93098ccf52af38f99756451cf
parentc953e3f09cc630999511dd567ff42abc26ea19b9 (diff)
parent7151bbc3ae29ea98c0a3f09b5ae4445da0b30a49 (diff)
downloadperlweeklychallenge-club-5cc1758323aeb82060065a7fe214bf4c6184f1e4.tar.gz
perlweeklychallenge-club-5cc1758323aeb82060065a7fe214bf4c6184f1e4.tar.bz2
perlweeklychallenge-club-5cc1758323aeb82060065a7fe214bf4c6184f1e4.zip
Merge pull request #707 from tagg/branch-for-challenge-028
Solutions to challenge 028
-rw-r--r--challenge-028/lars-thegler/README1
-rwxr-xr-xchallenge-028/lars-thegler/perl5/ch-1.pl21
-rwxr-xr-xchallenge-028/lars-thegler/perl5/ch-2.pl14
3 files changed, 36 insertions, 0 deletions
diff --git a/challenge-028/lars-thegler/README b/challenge-028/lars-thegler/README
new file mode 100644
index 0000000000..db6756665d
--- /dev/null
+++ b/challenge-028/lars-thegler/README
@@ -0,0 +1 @@
+Solution by Lars Thegler
diff --git a/challenge-028/lars-thegler/perl5/ch-1.pl b/challenge-028/lars-thegler/perl5/ch-1.pl
new file mode 100755
index 0000000000..ab8780f01e
--- /dev/null
+++ b/challenge-028/lars-thegler/perl5/ch-1.pl
@@ -0,0 +1,21 @@
+#!/usr/bin/env perl
+
+# Challenge 028, task #1:
+# Write a script to check the file content without explicitly reading the content.
+# It should accept file name with path as command line argument and print
+# “The file content is binary.” or else “The file content is ascii.” accordingly.
+
+use Modern::Perl;
+
+my $filename = shift;
+
+if ( -B $filename ) {
+ say 'The file content is binary.';
+} elsif ( -T $filename ) {
+ say 'The file content is ascii.';
+} else {
+ say 'The file is something else.';
+}
+
+# The task is worded in an unfortunate way - there exists files that are neither
+# binary nor ascii. My code handles that also.
diff --git a/challenge-028/lars-thegler/perl5/ch-2.pl b/challenge-028/lars-thegler/perl5/ch-2.pl
new file mode 100755
index 0000000000..3d4695ae9a
--- /dev/null
+++ b/challenge-028/lars-thegler/perl5/ch-2.pl
@@ -0,0 +1,14 @@
+#!/usr/bin/env perl
+
+# Write a script to display Digital Clock. Feel free to be as creative as you
+# can when displaying digits. We expect bare minimum something like “14:10:11”.
+
+use Modern::Perl;
+use Time::Piece;
+
+$|++;
+
+while (1) {
+ print "\r",localtime->datetime;
+ sleep 1;
+} \ No newline at end of file