diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2025-07-15 10:58:18 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-15 10:58:18 +0100 |
| commit | 5b94c6e008dcf8e18e3612a4ff5f4d28f72d2076 (patch) | |
| tree | 45100265e6a6533d8f716287958e1ba23e031f93 | |
| parent | eae5b74c71fd84286c8d143ba1ec438fa6cf3453 (diff) | |
| parent | 1963967c1ff9b63d1ea0a2a1d03dce2c65c24264 (diff) | |
| download | perlweeklychallenge-club-5b94c6e008dcf8e18e3612a4ff5f4d28f72d2076.tar.gz perlweeklychallenge-club-5b94c6e008dcf8e18e3612a4ff5f4d28f72d2076.tar.bz2 perlweeklychallenge-club-5b94c6e008dcf8e18e3612a4ff5f4d28f72d2076.zip | |
Merge pull request #12349 from pjcs00/wk330
Week 330 - Digitless Capitals
| -rw-r--r-- | challenge-330/peter-campbell-smith/blog.txt | 1 | ||||
| -rwxr-xr-x | challenge-330/peter-campbell-smith/perl/ch-1.pl | 32 | ||||
| -rwxr-xr-x | challenge-330/peter-campbell-smith/perl/ch-2.pl | 33 |
3 files changed, 66 insertions, 0 deletions
diff --git a/challenge-330/peter-campbell-smith/blog.txt b/challenge-330/peter-campbell-smith/blog.txt new file mode 100644 index 0000000000..69d6c6bea8 --- /dev/null +++ b/challenge-330/peter-campbell-smith/blog.txt @@ -0,0 +1 @@ +http://ccgi.campbellsmiths.force9.co.uk/challenge/330 diff --git a/challenge-330/peter-campbell-smith/perl/ch-1.pl b/challenge-330/peter-campbell-smith/perl/ch-1.pl new file mode 100755 index 0000000000..5f7158d76e --- /dev/null +++ b/challenge-330/peter-campbell-smith/perl/ch-1.pl @@ -0,0 +1,32 @@ +#!/usr/bin/perl + +# Blog: http://ccgi.campbellsmiths.force9.co.uk/challenge + +use v5.26; # The Weekly Challenge - 2025-07-14 +use utf8; # Week 330 - task 1 - Clear digits +use warnings; # Peter Campbell Smith +binmode STDOUT, ':utf8'; +use Encode; + +clear_digits('cab12'); +clear_digits('xy99'); +clear_digits('pa1erl'); +clear_digits('onlyletters'); +clear_digits('12345'); +clear_digits('sausage1234567x'); +clear_digits('chxy53f7occ 93oỸ4laps$393tt6ee0'); + +sub clear_digits { + + my ($string); + + # initialise + $string = shift; + say qq[\nInput: '$string']; + + # do it + $string = $1 . $2 while $string =~ m|^(.*)[^0-9][0-9](.*)$|; + + # say it + say qq[Output: '$string']; +} diff --git a/challenge-330/peter-campbell-smith/perl/ch-2.pl b/challenge-330/peter-campbell-smith/perl/ch-2.pl new file mode 100755 index 0000000000..1126c2f760 --- /dev/null +++ b/challenge-330/peter-campbell-smith/perl/ch-2.pl @@ -0,0 +1,33 @@ +#!/usr/bin/perl + +# Blog: http://ccgi.campbellsmiths.force9.co.uk/challenge + +use v5.26; # The Weekly Challenge - 2025-07-14 +use utf8; # Week 330 - task 2 - Title capital +use warnings; # Peter Campbell Smith +binmode STDOUT, ':utf8'; +use Encode; + +title_capital('PERL IS gREAT'); +title_capital('THE weekly challenge'); +title_capital('YoU ARE A stAR'); +title_capital('Der Nobelpreisträger Thomas Südhof spricht über eigene Fehler'); + +sub title_capital { + + my ($string, $new); + + # initialise + $string = shift; + + # do what it says + $new .= length($1) <= 2 ? + lc($1) . ' ' : + ucfirst(lc($1)) . ' ' + while $string =~ m|(\w+)|gu; + + # report + $new = substr($new, 0, -1); + say qq[\nInput: '$string']; + say qq[Output: '$new']; +} |
