aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLubos Kolouch <lubos@kolouch.net>2019-10-01 21:18:28 +0200
committerLubos Kolouch <lubos@kolouch.net>2019-10-01 21:18:28 +0200
commit5c6789e1f955c451d35388b15f7c19ade549d271 (patch)
treeba9092a68b213efe353d05180d759707c4302ef8
parentd2c1ece666ac11016f51e756bef3d7f0c9eae661 (diff)
downloadperlweeklychallenge-club-5c6789e1f955c451d35388b15f7c19ade549d271.tar.gz
perlweeklychallenge-club-5c6789e1f955c451d35388b15f7c19ade549d271.tar.bz2
perlweeklychallenge-club-5c6789e1f955c451d35388b15f7c19ade549d271.zip
First commit, file ch-1.pl
-rwxr-xr-xchallenge-027/arne-sommer/perl6/history-variable21
-rw-r--r--challenge-028/lubos-kolouch/perl5/ch-1.pl47
2 files changed, 47 insertions, 21 deletions
diff --git a/challenge-027/arne-sommer/perl6/history-variable b/challenge-027/arne-sommer/perl6/history-variable
deleted file mode 100755
index 7a2ff571f5..0000000000
--- a/challenge-027/arne-sommer/perl6/history-variable
+++ /dev/null
@@ -1,21 +0,0 @@
-#! /usr/bin/env perl6
-
-use lib "lib";
-
-use HistoryVariable;
-
-my $x = HistoryVariable.new;
-say $x;
-
-$x.set(10);
-say $x;
-
-$x.set(20);
-say $x;
-
-$x.set(5);
-say $x.get;
-
-say $x.get;
-say $x.history;
-say $x.history('time');
diff --git a/challenge-028/lubos-kolouch/perl5/ch-1.pl b/challenge-028/lubos-kolouch/perl5/ch-1.pl
new file mode 100644
index 0000000000..e1982c24a4
--- /dev/null
+++ b/challenge-028/lubos-kolouch/perl5/ch-1.pl
@@ -0,0 +1,47 @@
+#!/usr/bin/perl
+#===============================================================================
+#
+# FILE: ch-1.pl
+#
+# USAGE: ./ch-1.pl
+#
+# DESCRIPTION: https://perlweeklychallenge.org/blog/perl-weekly-challenge-028/
+#
+# 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.
+#
+# OPTIONS: ---
+# REQUIREMENTS: ---
+# BUGS: ---
+# NOTES: ---
+# AUTHOR: Lubos Kolouch
+# ORGANIZATION:
+# VERSION: 1.0
+# CREATED: 09/30/2019 01:20:02 PM
+# REVISION: ---
+#===============================================================================
+
+use strict;
+use warnings;
+use feature qw/say/;
+
+sub get_file_status {
+ my $file = shift;
+
+ return "The file does not exist." unless -e $file;
+
+ return "The file is not readable." unless -r $file;
+
+ return "The file is empty." if -z $file;
+
+ return "The file is not regular." unless -f $file;
+
+ return "The file content is ascii." if -T $file;
+
+ return "The file content is binary.";
+}
+
+my $file = shift || die 'Usage: ch-1.pl filename';
+
+say get_file_status($file);
+
+