aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJörg Sommrey <28217714+jo-37@users.noreply.github.com>2024-07-26 13:30:48 +0200
committerJörg Sommrey <28217714+jo-37@users.noreply.github.com>2024-07-26 16:37:18 +0200
commit744f4899ffdfde6039de3b6e7fd794b34522775a (patch)
treed95917646ee9e862cd0b593b6ce8d6c2d67636e3
parent373313e5bd3f5563f991fbd0a290b02f25cc3e91 (diff)
downloadperlweeklychallenge-club-744f4899ffdfde6039de3b6e7fd794b34522775a.tar.gz
perlweeklychallenge-club-744f4899ffdfde6039de3b6e7fd794b34522775a.tar.bz2
perlweeklychallenge-club-744f4899ffdfde6039de3b6e7fd794b34522775a.zip
Solution to task 2
-rwxr-xr-xchallenge-279/jo-37/perl/ch-2.pl60
1 files changed, 60 insertions, 0 deletions
diff --git a/challenge-279/jo-37/perl/ch-2.pl b/challenge-279/jo-37/perl/ch-2.pl
new file mode 100755
index 0000000000..6be9ea5a98
--- /dev/null
+++ b/challenge-279/jo-37/perl/ch-2.pl
@@ -0,0 +1,60 @@
+#!/usr/bin/perl -s
+
+use v5.24;
+use Test2::V0;
+
+our ($tests, $examples);
+
+run_tests() if $tests || $examples; # does not return
+
+die <<EOS unless @ARGV;
+usage: $0 [-examples] [-tests] [STR]
+
+-examples
+ run the examples from the challenge
+
+-tests
+ run some tests
+
+STR
+ a string
+
+EOS
+
+
+### Input and Output
+
+say +(qw(false true))[split_string(shift)];
+
+
+### Implementation
+#
+# For details see:
+# https://github.sommrey.de/the-bears-den/2024/07/26/ch-279.html#task-2
+
+
+sub split_string {
+ local $_ = shift;
+
+ !(tr/aeiouAEIOU// % 2);
+}
+
+
+### Examples and tests
+
+sub run_tests {
+ SKIP: {
+ skip "examples" unless $examples;
+
+ ok !split_string("perl"), 'example 1';
+ ok split_string("book"), 'example 2';
+ ok split_string("good morning"), 'example 3';
+ }
+
+ SKIP: {
+ skip "tests" unless $tests;
+ }
+
+ done_testing;
+ exit;
+}