in reply to Re^3: searching for keywords
in thread searching for keywords

Nice code. I just want to add if
while( m/\b([\w'-]+)\b/g ) {
replace by
while( m/\b([\w'-]+)\b/gi ) {
Your program becomes a case independed.

Replies are listed 'Best First'.
Re^5: searching for keywords
by davido (Cardinal) on Jan 18, 2006 at 08:41 UTC

    Not really. Your use of the /i switch is meaningless in this context. The point here is to pull words one by one from the text file, and see if there exists a hash element whos key matches that word. But hash keys themselves are case dependant. All that the regexp is doing is to grab one "word" at a time. That word still has to be found to be a hash key from the keyword hash. There is actually nothing in the regular expression I've used that would be affected by the /i switch in any way, other than to possibly slow down the regexp's execution speed.

    As a matter of fact, my solution is the only one posted thus far in this thread that wouldn't match case insensitively when the /i switch is added. Your post is a good observation if applied to the other answers provided in this thread.


    Dave