diff options
| author | Niels van Dijke <perlboy@cpan.org> | 2025-07-21 10:03:05 +0000 |
|---|---|---|
| committer | Niels van Dijke <perlboy@cpan.org> | 2025-07-21 10:03:05 +0000 |
| commit | 7567caefc0b1d2394ad2906543e93b65fab4818e (patch) | |
| tree | 70ddeb2e262d9295dd7fb8c85b43c103bb4157d6 | |
| parent | 94c86188d9c422542bb6f94ed2c363c901880a47 (diff) | |
| download | perlweeklychallenge-club-7567caefc0b1d2394ad2906543e93b65fab4818e.tar.gz perlweeklychallenge-club-7567caefc0b1d2394ad2906543e93b65fab4818e.tar.bz2 perlweeklychallenge-club-7567caefc0b1d2394ad2906543e93b65fab4818e.zip | |
Task 1 correction. We need the length, not the string itself
| -rwxr-xr-x | challenge-331/perlboy1967/perl/ch1.pl | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/challenge-331/perlboy1967/perl/ch1.pl b/challenge-331/perlboy1967/perl/ch1.pl index 5f1b23ab28..7d4786e960 100755 --- a/challenge-331/perlboy1967/perl/ch1.pl +++ b/challenge-331/perlboy1967/perl/ch1.pl @@ -19,12 +19,12 @@ use Test2::V0 qw(-no_srand); use exact 'v5.32', -signatures; sub lastWord ($str) { - ($str =~ m#(\S+)\b[\W]*$#)[0]; + length(($str =~ m#(\S+)\b[\W]*$#)[0]); } -is(lastWord(q{The Weekly Challenge}),'Challenge','Example 1'); -is(lastWord(q{ Hello World }),'World','Example 2'); -is(lastWord(q{Let's begin the fun}),'fun','Example 3'); -is(lastWord(q{Hello TWC!}),'TWC','Own example'); +is(lastWord(q{The Weekly Challenge}),9,'Example 1'); +is(lastWord(q{ Hello World }),5,'Example 2'); +is(lastWord(q{Let's begin the fun}),3,'Example 3'); +is(lastWord(q{Hello TWC!}),3,'Own example'); done_testing; |
