CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
syntax help with searching

 



perlkid
stranger

Feb 18, 2000, 3:31 PM

Post #1 of 6 (885 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).]


Cure
User

Feb 18, 2000, 7:23 PM

Post #2 of 6 (885 views)
Re: syntax help with searching [In reply to] Can't Post

Kinda lost here

Are you saying-> you want it to print all the content in the database--> so your not trying to find a keyword int the database-> you just want to pint the contents ina database--> Is this what you are saying?

Cure


perlkid
stranger

Feb 19, 2000, 2:55 AM

Post #3 of 6 (885 views)
Re: syntax help with searching [In reply to] Can't Post

 
Thanks cure but I think I figured out a better way that will work for me.

perlkid


Cure
User

Feb 19, 2000, 8:26 AM

Post #4 of 6 (885 views)
Re: syntax help with searching [In reply to] Can't Post

Hi

What kind of database are you using?

Cure


perlkid
stranger

Feb 19, 2000, 10:03 AM

Post #5 of 6 (885 views)
Re: syntax help with searching [In reply to] Can't Post

 
I want it so that when a keyword in database A has been searched for the results of the regular engine won't print. But when nothing is found in data base A the regular results are printed.

Thanks,

perlkid


perlkid
stranger

Feb 19, 2000, 6:04 PM

Post #6 of 6 (885 views)
Re: syntax help with searching [In reply to] Can't Post

 A pipe delimited db file.

I think that would be the proper description. Speaking of data bases, Do you know a way to convert a digital dat data base to an ascii data base?

perlkid



[This message has been edited by perlkid (edited 02-19-2000).]

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives