diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2025-07-15 10:58:58 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-15 10:58:58 +0100 |
| commit | 4defe3499e32a2ffd9871e548763285802f4b329 (patch) | |
| tree | 642ee224f96d2837e33d3208070e128c228568ce | |
| parent | 5b94c6e008dcf8e18e3612a4ff5f4d28f72d2076 (diff) | |
| parent | f28dd62af10e7bcc108fccb680cc06777d89d850 (diff) | |
| download | perlweeklychallenge-club-4defe3499e32a2ffd9871e548763285802f4b329.tar.gz perlweeklychallenge-club-4defe3499e32a2ffd9871e548763285802f4b329.tar.bz2 perlweeklychallenge-club-4defe3499e32a2ffd9871e548763285802f4b329.zip | |
Merge pull request #12350 from wlmb/challenges
Solve PWC 330
| -rw-r--r-- | challenge-330/wlmb/blog.txt | 1 | ||||
| -rwxr-xr-x | challenge-330/wlmb/perl/ch-1.pl | 20 | ||||
| -rwxr-xr-x | challenge-330/wlmb/perl/ch-2.pl | 12 |
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; |
