in reply to Counting instances in a hash from an array

When comparing strings, use eq, not ==. Using the latter will convert the strings into numbers before comparing them.

The proper syntax for if is if (...) { ... }. The parens are missing in your code.

Update: The OP updated his node to include sample data. It seems he is still storing the score (a number he wishes to change) as the key to the hash. He was told this was a bad idea, and he was given several solutions to his question in an earlier post.

Replies are listed 'Best First'.
Re^2: Counting instances in a hash from an array
by Melly (Chaplain) on Mar 23, 2006 at 23:22 UTC
    Is he? It looks more like he's trying to store the count as the hash-value (reasonable imho), and the word as the key - what have I missed?

    Tom Melly, tom@tomandlu.co.uk
      If you look at the code, he's incrementing the value, but if you look at his data (pasted below), the number to increment is in the key. It's not clear from that data that the left column is a key -- it could be an HoA -- but in the past, he explicitely said the score (the number to increment) is in the key.
      35 forc two bodi twice strong on bodi sai bodi mass 39 you expect on think new bodi made two bodi origin 60 attract bodi b origin force 46 total forc b twice origin force 34 sai on bodi twice mass three time mass forc six 17 on now see why bodi fall same rate bodi twice