divinus has asked for the wisdom of the Perl Monks concerning the following question:
After that it just prints out some default stuff and exits. But like I said its giving html and javascript results and really the only way I can think of changing that is to ignore everything in between the head tags (for javascript) and the tags (for the links which are my main problems). I hope I have made some sense here. Like I said, I'm more of a reader than a writer. I understand almost every line of this code, I just don't know how to correctly alter it. On a side note, the program also never prints out the title and istead prints the name of the file every time but thats not my biggest concern right now. If you have any advice on either of them I would appreciate it. Thanks. Divinus#!/usr/bin/perl #The following code deals with the form data if ($ENV{'REQUEST_METHOD'} eq 'POST') { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs =split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name}= $value; } } $keyword=$FORM{keyword}; print "Content-type: text/html\n\n"; print "<h2> Here are the files we found</h2>\n\n"; chdir("/usr/local/etc/httpd"); opendir(DIR, "."); while($file = readdir(DIR)) { next if ($file !~ /.htm/); open(FILE, $file); $foundone = 0; $title = ""; while (<FILE>) { if (/$keyword/i) { $foundone = 1; } if (/<TITLE>/) { chop; $title = $_; $title =~ s/<TITLE>//g; $title =~ s/<\TITLE>//g; } } if ($title eq "") { $title = $file; } if($foundone) { print "<A HREF=/$file>$title</A><BR>"; $listed=1; } close(FILE);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Search Engine troubles
by Cine (Friar) on Aug 21, 2001 at 22:45 UTC | |
by divinus (Acolyte) on Aug 21, 2001 at 23:14 UTC | |
by Cine (Friar) on Aug 21, 2001 at 23:20 UTC | |
by divinus (Acolyte) on Aug 21, 2001 at 23:34 UTC | |
by Cine (Friar) on Aug 21, 2001 at 23:38 UTC | |
|
Re: Search Engine troubles
by Beatnik (Parson) on Aug 21, 2001 at 22:46 UTC | |
|
Re: Search Engine troubles
by perrin (Chancellor) on Aug 22, 2001 at 01:36 UTC |