aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Muth <matthias.muth@gmx.de>2024-04-28 22:36:42 +0200
committerMatthias Muth <matthias.muth@gmx.de>2024-04-28 22:36:42 +0200
commit7ffe23d87b053bf4af6ae8724210b0060a3ebbae (patch)
tree4d3e7309800bd8af94ce4d4bf1a96f1406dbfed4
parent1368b80e4471fc70286164e81af24cb4be769f9a (diff)
downloadperlweeklychallenge-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-xchallenge-266/matthias-muth/perl/ch-1.pl5
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 : "";
}