in reply to Out of Memory

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.

Replies are listed 'Best First'.
Re^2: Out of Memory
by Anonymous Monk on Oct 25, 2009 at 05:18 UTC
      That is indeed an implementation of the previously mentioned data structure. I've never used it or other modules, thus the lack of recommendation.