http://www.perlmonks.org?node_id=25446


in reply to Search engine

foreach $i (keys %Index_db) { if ($i == $id) { @fileId = split( /:/, $Index_db{$i}); . . . } }

Why are you iterating over the keys of this hash? surely you should just do:

$id = $Words_db{$word}; @fileId = split( /:/, $Index_db{$id});

And that would have the same effect in a much shorter time.

Why do you have two hashes if the first only holds an index into the second. Reading over this it looks like you were previously using an array for Index_db, and that the hash held the array index where you could find the information. I think you should look at the code again as you can probably do without the Words_db hash, and clean up the logic to exploit the hash you are using.

Nuance

Replies are listed 'Best First'.
RE: RE: Search engine
by larsen (Parson) on Aug 01, 2000 at 17:41 UTC
    Oh yes, surely. I think this is a very old version of my code (by the way, I think one has to be very stupid to write something like this).
    I hope there's a way to decrease monks' experience :) Thank you.
    Larsen
      You don't have to be stupid to write that, if you've been dealing with a problem for a long time sometimes you forget why you made certain implementation decisions. Often a "fresh" pair of eyes see things that you missed because you are "too familiar" with them.

      Nuance