From 5c6789e1f955c451d35388b15f7c19ade549d271 Mon Sep 17 00:00:00 2001 From: Lubos Kolouch Date: Tue, 1 Oct 2019 21:18:28 +0200 Subject: First commit, file ch-1.pl --- challenge-027/arne-sommer/perl6/history-variable | 21 ----------- challenge-028/lubos-kolouch/perl5/ch-1.pl | 47 ++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 21 deletions(-) delete mode 100755 challenge-027/arne-sommer/perl6/history-variable create mode 100644 challenge-028/lubos-kolouch/perl5/ch-1.pl 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); + + -- cgit