in reply to Out of Memory

[ Duplicate post. Please ignore ]

Use a trie instead of a hash table.


For future reference,

if(exists $wordCount{$_}) { $wordCount{$_} = $wordCount{$_} + 1; } else { $wordCount{$_} = 1; }

can be shortened to

++$wordCount{$_};

It won't help your memory problem, just your code clarity.