simple search script

simple search script

am 19.11.2004 04:27:57 von Ken Saunders

Below is the script I've been working on. I know theres something
wrong with it but can't find it for the life of me. Can someone help
me get this running. Its supposed to search my all of my files and
return a page with the matchs. I had this working as an html file and
a cgi but when I tried to merge the two it go broken. Thanks everyone

#!/usr/bin/perl
# Ken Saunders
#11/16/2004
#itc 216
#assignment 3
#this perl script displays a search form, and searchs for matchs on
html files

use strict;
use File::Find;
use CGI;

#variable - query
my $query = param("query");

# There's nothing in the query string
if ($query eq '')
{
print header();
print start_html();

# Displays the search form
print q(

);
print q();
print q();
print q(
);

print end_html();

# Bail out early if there are no results to print
exit;

#$filePath = $File::Find::name;
#$filePath =~
s/(home\/classes\/ksaund01\/public_html)/~ksaund01/ig
}

#prints the header wiht the query name in an ordered list
print header();
print start_html();
print "\n

For the query $query, these results were
found:

\n
    \n";
    undef $/;

    #search
    find( sub
    {
    return if($_ =~ /^\./);
    return unless($_ =~ /\.html/i);
    stat $File::Find::name;
    return if -d;
    return unless -r;

    open(FILE, "< $File::Find::name") or return;
    my $string = ;
    close (FILE);

    return unless ($string =~ /\Q$query\E/i);
    my $page_title = $_;
    if ($string =~ /(.*?)<\/title>/is)<br /> {<br /> $page_title = $1;<br /> }<br /> print "<li></li>\n";<br /> },<br /> '/~ksaund01/page1.html');<br /> <br /> print "</ol>\n";<br /> print end_html();<br /> End</p> </article> <article> <h2>Re: simple search script</h2><span>am 19.11.2004 09:10:07 von Tintin</span> <p>"Ken Saunders" <bnbliss@comcast.net> wrote in message <br /> news:6tpqp051t1abqevorp0vv91b21903nti2r@4ax.com...<br /> > Below is the script I've been working on. I know theres something<br /> > wrong with it but can't find it for the life of me. Can someone help<br /> > me get this running. Its supposed to search my all of my files and<br /> > return a page with the matchs. I had this working as an html file and<br /> > a cgi but when I tried to merge the two it go broken. Thanks everyone<br /> <br /> [snip script]<br /> <br /> Please read http://www.cs.tut.fi/~jkorpela/usenet/xpost.html</p> </article> <footer> <a href="/">Index</a> | <a href="/impressum.php">Impressum</a> | <a href="/datenschutz.php">Datenschutz</a> | <a href="https://www.xodox.de/">XODOX</a> </footer> </main> </body> </html>