
perlkid
stranger
Feb 18, 2000, 3:31 PM
Post #1 of 6
(351 views)
|
|
syntax help with searching
|
Can't Post
|
|
Hi guys, I am trying to get results on this search engine to not print only when certain words are searched for. I tried this <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> open(FILE,"/my/path/to/the/keywords/database.db"); @real=<FILE>; close(FILE); foreach $line(@real) { @fields=split(/\|/,$line); $fields[0]=lc($fields[0]); if ($fields[0] ne "$ENV{'MY_QUERY'}") { print "$results"; }} </pre><HR></BLOCKQUOTE> But then when you search it duplicates the results for each line in the data base! When I change the if condition to eq instead of ne It does what I would want if you search for something that's not a keyword in the data base. Basicaly it's backwards. With eq it print the results when something is in the keywords data base but when you search in something that not in the keywords data base it prints nothing. See, backwards I tell yah. So is there any way I could get rid of the for each and still have it work? Because I think If there weren't any for each brackets It would work. Thanks, perlkid [This message has been edited by perlkid (edited 02-18-2000).]
|