|No such thing as a small change|
Re: compute the occurrence of words ("under stand arrays")by ww (Bishop)
|on Feb 13, 2013 at 14:32 UTC||Need Help??|
First: I second Utilitarian's (implied) advice re hashes.
Second: The shebang line is unnecessary under windows unless you have trailing modifies ( like -T or -w ) and definitely doesn't need escaped backslashes.
Third: these are a couple ways to do PART of what your code tries to do -- count the words.
Note that the highest numeric value from the array method is 25, even though there are 26 words in the __DATA__ section. Look at the first value of the output and you'll find a zero... which is the way array elements are denominated -- the first element is $array.
If you wish to see the NON-ARRAY method used, move the =head and =cut down to surround the second (and currently operative) code. The data section must, of course, stay outside this hackish method of doing a multi-line comment in a script.
BUT, to identify and count unique words using the commonly recommended approach, use a hash.
And finally, if by any chance you mean you're seeing things like HASH(0x213F7) when you mention "numeric values," (though I don't see why) what you're seeing is effectively a pointer to the memory where the actual values are stored; to understand that (and how to get the actual values) you'll need to study referencing and dereferencing, in our estimable Tutorials section.