Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: Search Algorithm

by lhoward (Vicar)
on Aug 10, 2000 at 17:38 UTC ( #27283=note: print w/replies, xml ) Need Help??

in reply to Search Algorithm

Two ideas come to mind. I don't think that either of these would be spectacularly faster than what you are doing now, but they may provide some modest improvement.

The following idea relies on you being able to break each line up into "words" to match against your list. If that is not possible ignore this suggestion.

read in all the keywords from a file into a hash as keys get a listing of all the files I want to search into an array, for each file { for each line { for each word in the line { if word is in hash of wanted words{ log existance of the word } } } }
You may also be able to get it going faster by putting all the words into a single regular-expression, compiling the RE once and then checking each line of each file against that RE. (this will only work if you want to know if "at least one" of the words is in a line and don't care exactly which one it was).
read in all the keywords from a file and make them into a regular expr +ession get a listing of all the files I want to search into an array, for each file { for each line { if line match RE { log it } } }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://27283]
[james28909]: i know but scroll through your calendar on your computer.
[james28909]: i thiught you were going to say make both hands into a fist and puch yourself in the face
[atcroft]: .oO(Sorry, I probably should have said take two normal hands....)
[atcroft]: james28909: No, unless you are a politician, I wouldn't say that (and even if you are, I still probably wouldn't say that).
[james28909]: i mean how hard can it be? its just subtracting days lol
[atcroft]: james28909: What about October 5, 1582?
[stevieb]: atcroft: "Make both hands into fists..."... is something my Ma taught me in our native lang, but I was to ignorant and young to pay attention. Thanks for that :)
[atcroft]: stevieb: Sad to say that I only recently learned that particular trick, but I have since found it very useful.... :)
[james28909]: ill be back with a solution eventually
[stevieb]: it's a reminder to re-inforce it :P

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2017-04-29 04:33 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (531 votes). Check out past polls.