my %foo; my $string = 'Poet Blake had a milky white cat. He used to call it Pussy.'; for my $word (split /\s+/, $string) { $foo{$word}++; }