From 7ffe23d87b053bf4af6ae8724210b0060a3ebbae Mon Sep 17 00:00:00 2001 From: Matthias Muth Date: Sun, 28 Apr 2024 22:36:42 +0200 Subject: Challenge 266 Task 1 and 2 solutions in Perl by Matthias Muth --- challenge-266/matthias-muth/perl/ch-1.pl | 5 +++-- 1 file 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 : ""; } -- cgit