He Brian,
  In Perl, you don't have to declare your variables if you don't want to.
You are building the count hash on the fly here.  All you are doing is
incrementing itself by one everytime the word is found.

@words=('test','this','that','test');
for $word (@words) {
  $count{$word}=$count{$word}+1;
  # same as $count{$word}++;
}

will give you:
  $count{'test'} = 2
  $count{'this'} = 1
  $count{'that'} = 1


Shawn

> foreach $word (@words){ # for every element of the array @words..........
>      $count {$word} = $count {$word} + 1; # or $count {$word}++ # I get a
> bit lost here!! Is $count the value of the key $word in a hash?
> }
>
> foreach $word (keys %count) {#How did %count come about?
>      print "$word was seen $count {$word} times\n";
> }



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to