in reply to hash to count words
Your regex "$word =~ s/^\w\x\//g;" is invalid.
you probably want:
Your re-initilazation of "%hash=()" within the loop makes the hash useless.$word=~s/[^\w]//g; # Eliminate non-word chars
Declare it outside the loop, and add data to it using
Later , you can get a list of words found by accessing:$hash{$word}++; # Get a count of the word
Please try to follow davido's excellent advice in response to your previous question on the same subject.keys (%hash)
I hope life isn't a big joke, because I don't get it.
-SNL
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: hash to count words
by underoathed (Initiate) on Sep 13, 2012 at 14:46 UTC | |
by NetWallah (Canon) on Sep 13, 2012 at 15:46 UTC | |
by AnomalousMonk (Archbishop) on Sep 13, 2012 at 16:18 UTC | |
by underoathed (Initiate) on Sep 17, 2012 at 12:59 UTC | |
by AnomalousMonk (Archbishop) on Sep 17, 2012 at 19:52 UTC |