aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJörg Sommrey <28217714+jo-37@users.noreply.github.com>2024-09-13 11:29:20 +0200
committerJörg Sommrey <28217714+jo-37@users.noreply.github.com>2024-09-13 14:37:57 +0200
commit517cccfd3ccf75aab663b3ce820eae0479ed0400 (patch)
tree008f577328906d6de0c86501974b5f40ab5421bd
parent92704d24e719f7514dcfc74a71fa03f1ea8f8f06 (diff)
downloadperlweeklychallenge-club-517cccfd3ccf75aab663b3ce820eae0479ed0400.tar.gz
perlweeklychallenge-club-517cccfd3ccf75aab663b3ce820eae0479ed0400.tar.bz2
perlweeklychallenge-club-517cccfd3ccf75aab663b3ce820eae0479ed0400.zip
Solution to task 1
-rwxr-xr-xchallenge-286/jo-37/perl/ch-1.pl7
-rwxr-xr-xchallenge-286/jo-37/perl/ch-1a.sh7
2 files changed, 14 insertions, 0 deletions
diff --git a/challenge-286/jo-37/perl/ch-1.pl b/challenge-286/jo-37/perl/ch-1.pl
new file mode 100755
index 0000000000..ad5d8fd247
--- /dev/null
+++ b/challenge-286/jo-37/perl/ch-1.pl
@@ -0,0 +1,7 @@
+#!/usr/bin/perl -w0777
+
+use v5.12;
+seek DATA, 0, 0;
+say +(keys %{ {<DATA> =~ /(\S+)()/g} })[0];
+__DATA__
+Hello David!
diff --git a/challenge-286/jo-37/perl/ch-1a.sh b/challenge-286/jo-37/perl/ch-1a.sh
new file mode 100755
index 0000000000..9386ee22f8
--- /dev/null
+++ b/challenge-286/jo-37/perl/ch-1a.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+# usage: ch-1.sh [N]
+# call ch-1.pl N times (default: 80), count the individual printed words
+# and sort by frequency
+
+for i in $(seq 1 ${1:-80}); do ./ch-1.pl; done | sort | uniq -c | sort -n