I have a search engine which is working fine but I want to add a couple of features to it such as a title to a search which has found a match. A heading something like here are your Search Results. I would also like to number the results and keep the number of matches to 10 on a page.

I would be very grateful if some one could help me!!!

Here is the code

#!/usr/bin/perl require "get_form_data.pl"; &get_form_data(); $search_term = $FORM{'search'}; my @match; opendir(DIR, "."); while($file = readdir(DIR)) { next if($file !~ /.html/); open(FILE, $file); $found_match = 0; $title = ""; while(<FILE>) { if(/$search_term/i) { $found_match = 1; } if((/<TITLE>/) || ($found_title)) { if((/<\/TITLE>/) && (/<TITLE>/)) { chop; $title = $_; $title =~ s/<TITLE>//g; $title =~ s/<\/TITLE>//g; } else { if($found_title == 1) { $title = $_; $found_title = 2 } elsif($found_title == 2) { $found_title = 0; } else { $found_title = 1; } } } } if($found_match) { push @match, qq ( <HTML>\n<BODY BGCOLOR=\"#000099\"link=\"#FFFF00\">\n <font face=\"Verdana\"><A HREF="$file">$title</A></font><p>\n ); } close(FILE); } closedir(DIR); # now output print "Content-type: text/html\n\n"; if (@match) { for (@match) { print; } } else { print "<HTML>\n<BODY BGCOLOR=\"#000099\"TEXT=\"#FFFFFF\">\n"; print "<H3>\n"; print "<font face=\"Verdana\">Sorry!!!</font>\n"; print "</H3>\n"; print "<font face=\"Verdana\">Sorry, we were unable to match your qu +ery<p>Please use the <STRONG>FEEDBACK</STRONG> button</font>\n"; print "<font face=\"Verdana\">to go to the form and let us know what + you are looking for.</font>\n\n"; } exit;

2001-04-05 Edit by Corion: Added formatting and CODE tags, changed title


In reply to Search engine result limiting (was: help!!) by bobbyboy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.