aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuis Mochan <mochan@fis.unam.mx>2025-07-14 11:10:50 -0600
committerLuis Mochan <mochan@fis.unam.mx>2025-07-14 11:10:50 -0600
commitf28dd62af10e7bcc108fccb680cc06777d89d850 (patch)
tree5b55cf4c2c2c061930bbcb56e19d99c656f657f9
parent6345c73edaafe1c1252e99cf8991c8fc27890445 (diff)
downloadperlweeklychallenge-club-f28dd62af10e7bcc108fccb680cc06777d89d850.tar.gz
perlweeklychallenge-club-f28dd62af10e7bcc108fccb680cc06777d89d850.tar.bz2
perlweeklychallenge-club-f28dd62af10e7bcc108fccb680cc06777d89d850.zip
Solve PWC 330
-rw-r--r--challenge-330/wlmb/blog.txt1
-rwxr-xr-xchallenge-330/wlmb/perl/ch-1.pl20
-rwxr-xr-xchallenge-330/wlmb/perl/ch-2.pl12
3 files changed, 33 insertions, 0 deletions
diff --git a/challenge-330/wlmb/blog.txt b/challenge-330/wlmb/blog.txt
new file mode 100644
index 0000000000..9a2eddb4c9
--- /dev/null
+++ b/challenge-330/wlmb/blog.txt
@@ -0,0 +1 @@
+https://wlmb.github.io/2025/07/14/PWC330/
diff --git a/challenge-330/wlmb/perl/ch-1.pl b/challenge-330/wlmb/perl/ch-1.pl
new file mode 100755
index 0000000000..3821ff49a1
--- /dev/null
+++ b/challenge-330/wlmb/perl/ch-1.pl
@@ -0,0 +1,20 @@
+#!/usr/bin/env perl
+# Perl weekly challenge 330
+# Task 1: Clear Digits
+#
+# See https://wlmb.github.io/2025/07/14/PWC330/#task-1-clear-digits
+use v5.36;
+die <<~"FIN" unless @ARGV;
+ Usage: $0 S1 S2...
+ to repeatedly remove digits from the string Sn, together with the closest
+ non-digit to its left.
+ Only lowercase letters and digits are allowed in the strings.
+ FIN
+for(@ARGV){
+ my $input=$_;
+ say("Only digits and lowercase letters allowed: $input"), next
+ unless /^[a-z0-9]*$/;
+ 1 while s/[a-z][0-9]//; #strip all letter-digit pairs
+ say("Couldn't strip all digits: $input -> $_"), next if /[0-9]/;
+ say "$input -> $_";
+}
diff --git a/challenge-330/wlmb/perl/ch-2.pl b/challenge-330/wlmb/perl/ch-2.pl
new file mode 100755
index 0000000000..da3d717b33
--- /dev/null
+++ b/challenge-330/wlmb/perl/ch-2.pl
@@ -0,0 +1,12 @@
+#!/usr/bin/env perl
+# Perl weekly challenge 330
+# Task 2: Title Capital
+#
+# See https://wlmb.github.io/2025/07/14/PWC330/#task-2-title-capital
+use v5.36;
+die <<~"FIN" unless @ARGV;
+ Usage: $0 S1 S2...
+ to convert words in the space-separated strings Sn to titlecase
+ or to lowercase if their length exceeds or not 2 characters.
+ FIN
+say join " ", map {(length($_) >2 && ucfirst)||$_} split " ", lc for @ARGV;