diff options
| author | Matthias Muth <matthias.muth@gmx.de> | 2024-04-28 22:36:42 +0200 |
|---|---|---|
| committer | Matthias Muth <matthias.muth@gmx.de> | 2024-04-28 22:36:42 +0200 |
| commit | 7ffe23d87b053bf4af6ae8724210b0060a3ebbae (patch) | |
| tree | 4d3e7309800bd8af94ce4d4bf1a96f1406dbfed4 | |
| parent | 1368b80e4471fc70286164e81af24cb4be769f9a (diff) | |
| download | perlweeklychallenge-club-7ffe23d87b053bf4af6ae8724210b0060a3ebbae.tar.gz perlweeklychallenge-club-7ffe23d87b053bf4af6ae8724210b0060a3ebbae.tar.bz2 perlweeklychallenge-club-7ffe23d87b053bf4af6ae8724210b0060a3ebbae.zip | |
Challenge 266 Task 1 and 2 solutions in Perl by Matthias Muth
| -rwxr-xr-x | challenge-266/matthias-muth/perl/ch-1.pl | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/challenge-266/matthias-muth/perl/ch-1.pl b/challenge-266/matthias-muth/perl/ch-1.pl index a5031ee602..3272df450a 100755 --- a/challenge-266/matthias-muth/perl/ch-1.pl +++ b/challenge-266/matthias-muth/perl/ch-1.pl @@ -11,10 +11,11 @@ use v5.36; sub uncommon_words( $line1, $line2 ) { + my @all_words = "$line1 $line2" =~ /(\w+)/g; my %word_counts; ++$word_counts{$_} - for "$line1 $line2" =~ /(\w+)/ig; - my @results = grep $word_counts{$_} == 1, "$line1 $line2" =~ /(\w+)/ig; + for @all_words; + my @results = grep $word_counts{$_} == 1, @all_words; return @results ? @results : ""; } |
