for my $word (@{ $self->{keywords} }) { my $word_score = 0; $word_score += 1 + ($content =~ tr/ / /) if $content =~ /\b\Q$word\E\b/i; $matches{$word} = $word_score; }