I'm using a simple search script (Matt Wright's Simple Search, to be specific) but I want to search only the Meta tag Keywords and the document's title (in the <title> tag). I'm not a programmer, so am not exactly sure how to break it down the search to only those areas. Right now, it searches the whole file contents.<br><br>Also, when there are NO keywords found, it prints only the header and footer with the area where the results should be as blank. How can I make it say that "there were no results, please try again?"<br><br>Thanks!<br><br>DonP<br><br>Here is the script as it is now:<br><br>#!/usr/bin/perl<br>##############################################################################<br># Simple Search Version 1.0 #<br># Copyright 1996 Matt Wright <A HREF="mailto:mattw@worldwidemart.com">mattw@worldwidemart.com</A> #<br># Created 12/16/95 Last Modified 12/16/95 #<br># Scripts Archive at: <A HREF=" TARGET="_new"> COPYRIGHT NOTICE #<br># Copyright 1996 Matthew M. Wright All Rights Reserved. #<br># #<br># Simple Search may be used and modified free of charge by anyone so long as #<br># this copyright notice and the comments above remain intact. By using this #<br># code you agree to indemnify Matthew M. Wright from any liability that # <br># might arise from it's use. # <br># #<br># Selling the code for this program without prior written consent is #<br># expressly forbidden. In other words, please ask first before you try and #<br># make money off of my program. #<br># #<br># Obtain permission before redistributing this software over the Internet or #<br># in any other medium. In all cases copyright and header must remain intact.#<br>##############################################################################<br># Define Variables <br><br>$basedir = '/path/html/';<br>$baseurl = '<A HREF=" TARGET="_new"> = ('*.shtml','*.html','*.htm');<br>$title = "Site Name";<br>$title_url = '<A HREF=" TARGET="_new"> '<A HREF=" TARGET="_new"> = 'bitmaps/';<br><br># Done #<br>##############################################################################<br><br># Parse Form Search Information<br>&parse_form;<br><br># Get Files To Search Through<br>&get_files;<br><br># Search the files<br>&search;<br><br># Print Results of Search<br>&return_html;<br><br>sub parse_form {<br><br> # Get the input<br> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});<br><br> # Split the name-value pairs<br> @pairs = split(/&/, $buffer);<br><br> foreach $pair (@pairs) {<br> ($name, $value) = split(/=/, $pair);<br><br> $value =~ tr/+/ /;<br> $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;<br><br> $FORM{$name} = $value;<br> }<br>}<br><br>sub get_files {<br><br> chdir($basedir);<br> foreach $file (@files) {<br> $ls = `ls $file`;<br> @ls = split(/\s+/,$ls);<br> foreach $temp_file (@ls) {<br> if (-d $file) {<br> $filename = "$file$temp_file";<br> if (-T $filename) {<br> push(@FILES,$filename);<br> }<br> }<br> elsif (-T $temp_file) {<br> push(@FILES,$temp_file);<br> }<br> }<br> }<br>}<br><br>sub search {<br><br> @terms = split(/\s+/, $FORM{'terms'});<br><br> foreach $FILE (@FILES) {<br><br> open(FILE,"$FILE"<br> @LINES = <FILE>;<br> close(FILE);<br><br> $string = join(' ',@LINES);<br> $string =~ s/\n//g;<br> if ($FORM{'boolean'} eq 'all') {<br> foreach $term (@terms) {<br> if ($FORM{'case'} eq 'Case Insensitive') {<br> if (!($string =~ /$term/i)) {<br> $include{$FILE} = 'no';<br> last;<br> }<br> else {<br> $include{$FILE} = 'yes';<br> }<br> }<br> elsif ($FORM{'case'} eq 'Case Sensitive') {<br> if (!($string =~ /$term/)) {<br> $include{$FILE} = 'no';<br> last;<br> }<br> else {<br> $include{$FILE} = 'yes';<br> }<br> }<br> }<br> }<br> elsif ($FORM{'boolean'} eq 'any') {<br> foreach $term (@terms) {<br> if ($FORM{'case'} eq 'Insensitive') {<br> if ($string =~ /$term/i) {<br> $include{$FILE} = 'yes';<br> last;<br> }<br> else {<br> $include{$FILE} = 'no';<br> }<br> }<br> elsif ($FORM{'case'} eq 'Sensitive') {<br> if ($string =~ /$term/) {<br> $include{$FILE} = 'yes';<br> last;<br> }<br> else {<br> $include{$FILE} = 'no';<br> }<br> }<br> }<br> }<br> if ($string =~ /<title>(.*)<\/title>/i) {<br> $titles{$FILE} = "$1";<br> }<br> else {<br> $titles{$FILE} = "$FILE";<br> }<br> }<br>}<br> <br>sub return_html {<br> print "Content-type: text/html\n\n";<br> print "<html>\n <head>\n <title>$FORM{'title'}</title>\n </head>\n";<br> print "<BODY Background=\"$images/bg.gif\" TEXT=\"#000000\" LINK=\"#8C1919\" ALINK=\"#8C1919\" VLINK=\"#8C1919\">\n";<br> print "<FONT FACE=\"Arial,Helvetica,Helv\"><FONT SIZE=+2>\n";<br> print "<CENTER><B><H2>$FORM{'title'}</H2></B></center>\n";<br> print "<P><FONT SIZE=+1>\n";<br> print "<B>$FORM{'body'}<p>\n";<br> print "<B><hr size=6 width=80%>\n";<br> print "<P><ul>\n";<br> print "<FONT SIZE=+0>\n";<br> foreach $key (keys %include) {<br> if ($include{$key} eq 'yes') {<br> print "<P><li><a href=\"$baseurl$key\">$titles{$key}</a>\n";<br> }<br> }<br> print "</ul>\n";<br> print "<ul>\n";<br> $i = 0;<br> foreach $term (@terms) {<br> $i++;<br> if (!($i == @terms)) {<br> print " ";<br> }<br> }<br> print "\n";<br> print "</ul>\n";<br>}<br>