On Mar 8, 2004, at 4:19 PM, Stuart White wrote:

Conceptually, what you say the result is, is what I
want, thanks.  When I read it though, without the
comment, I'd guess that the program would pair those
words like so:
dog:cat, dog:lizard, dog:wombat
with dog:lizard overwriting dog:cat, and dog:wombat
overwriting dog:lizard.
I seem to remember an example like this from the Llama
book.

However, absent my confusion, and given you're
correct, would this:
foreach (@words) {
$seen{$_}++;

This is where the work gets done, yes. In English it reads, for every word in the array, add one to the corresponding hash value under that key. That will give you a hash with keys for all the words. Their values will be the number of times that word appeared in the array. That's often useful, but in this case we can safely discard the values as the keys alone provide our answer. Make sense?


James


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to