sub count { # pass it the long sentence and the match word/char! my ($LONG,$CHAR) = @_; my $count = 0; while ($LONG=~m/$CHAR/) { $LONG=~s/$CHAR//; # remove match? $count++; } return $count; } #### foreach ( @check ) { print "[$_]: " . count($string,$_); }