diff options
| author | woznotwoz <woznotwoz@users.noreply.github.com> | 2025-07-15 16:53:59 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-15 16:53:59 -0700 |
| commit | 5286bf621666c377bdfb7fdebce4bf9d1992a2a5 (patch) | |
| tree | 8592cce36fdab73e6e51aa5b93676805804c33ab | |
| parent | 2a0212376723f736d69b19446317f474ade11baf (diff) | |
| download | perlweeklychallenge-club-5286bf621666c377bdfb7fdebce4bf9d1992a2a5.tar.gz perlweeklychallenge-club-5286bf621666c377bdfb7fdebce4bf9d1992a2a5.tar.bz2 perlweeklychallenge-club-5286bf621666c377bdfb7fdebce4bf9d1992a2a5.zip | |
Create ch-330.pl
| -rw-r--r-- | challenge-330/woznotwoz/perl/ch-330.pl | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/challenge-330/woznotwoz/perl/ch-330.pl b/challenge-330/woznotwoz/perl/ch-330.pl new file mode 100644 index 0000000000..f6b65f32e5 --- /dev/null +++ b/challenge-330/woznotwoz/perl/ch-330.pl @@ -0,0 +1,16 @@ +#! perl +use v5.40.0; +use Test2::V0 -no_srand => 1; + +is remove_digits('cab12'), 'c', 'first example'; +is remove_digits('xy99'), '', 'second example'; +is remove_digits('99999xy'), 'xy', 'third example'; +done_testing; + +sub remove_digits ($str) { + $str = substr($str,1) while $str =~ /^\d/; + while ($str =~ /\d/) { + $str =~ s/.\d//; + } + $str; +} |
