Help for this page

Select Code to Download


  1. or download this
    my %foo;
    my $string = 'Poet Blake had a milky white cat. He used to call it Pus
    +sy.';
    for my $word (split /\s+/, $string) {
       $foo{$word}++;
    }
    
  2. or download this
    my $cnt;
    for my $word (keys %foo) {
        $cnt++ if $bar{$word};
    }
    
  3. or download this
    my $word_count = scalar keys %foo;