in reply to Hash of Arrays versus Two Hashes

Is it just me or does this problem just scream OO? You have a bunch of data and a bunch of non-trivial work to do on that data. Why not create an object for each document's scoring? That way, you have a bunch of objects. You then have a really neat way of determing the list to display.
my $search_string = $cgi->param('search_string'); my @display_these = map { $_->[1] } # Strip off the ST sort { $a->[0] <=> $b->[0] } # Do the actual sort grep { $_->[0] > 0 } # Remove anything that scores a 0 map { [ $_->score($search_string), $_ ] } # Create the modified ST @document_objects;
The object would have a list of its words and how it scores. The object will probably be a hash (if you're lazy) or an array (if you're worried about space/speed). You'll have a hash of words that will key into hashrefs (cause they take less space when small) for all the ways something can score for that word. I dunno. :-)

Plus, you left out the part where this is really a 3-level structure, not a 2-level structure. You probably don't think of it that way, but you are de-referencing one level before you even get to the code posted above.

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.