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. :-)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;
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.
In reply to Re: Hash of Arrays versus Two Hashes
by dragonchild
in thread Hash of Arrays versus Two Hashes
by Cody Pendant
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |