use strict; use warnings; my @ban = ( ['bleep\w*', 1], ['bloop\w*', 1], ['blark\w*', 2], ['blank', 1], ); my $text = join '', ; print check($text); sub check { my ($score, $word) = 0; $_ = lc($_[0]); s/\W+/ /g; for $word (@ban) { $score += m/\b$word->[0]\b/ * $word->[1]; } return $score; } __DATA__ Bleeping blooper! Blark you! Blank!