K
Ken Saunders
I'm writing a script to search through all of my html files and return
the results of the query. I have used an html form file in the past I
want to integrate it all into one cgi file. can someone help here is
the code I've come up with.
#!perl -w
use strict;
use File::Find;
use CGI qw
standard);
print "Content-type: text/html\n\n";
print "<HTML><HEAD>";
print "<TITLE>Ken's Site Search</TITLE>";
print "</HEAD>";
print "<BODY>";
print <form action="/cgi-bin/assignment_3.cgi" method="post">;
print <input type="text" name="quety" size="40" /> ;
print <input type="submit" /> ;
print </form>;
print "</BODY></HTML>";
my $query = param("query");
print header();
print start_html();
print "\n<p>For the query $query, these results were
found:</p>\n<ol>\n";
undef $/;
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 = <FILE>;
close (FILE);
return unless ($string =~ /\Q$query\E/i);
my $page_title = $_;
if ($string =~ /<title>(.*?)<\/title>/is)
{
$page_title = $1;
}
print "<li><a href=\"$File::Find::name\">$page_title</a></li>\n";
},
'/home/ksaund01/public_html');
print "</ol>\n";
print end_html();
End
Were am I going wrong, any help is most appreciated.
(e-mail address removed)
the results of the query. I have used an html form file in the past I
want to integrate it all into one cgi file. can someone help here is
the code I've come up with.
#!perl -w
use strict;
use File::Find;
use CGI qw
print "Content-type: text/html\n\n";
print "<HTML><HEAD>";
print "<TITLE>Ken's Site Search</TITLE>";
print "</HEAD>";
print "<BODY>";
print <form action="/cgi-bin/assignment_3.cgi" method="post">;
print <input type="text" name="quety" size="40" /> ;
print <input type="submit" /> ;
print </form>;
print "</BODY></HTML>";
my $query = param("query");
print header();
print start_html();
print "\n<p>For the query $query, these results were
found:</p>\n<ol>\n";
undef $/;
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 = <FILE>;
close (FILE);
return unless ($string =~ /\Q$query\E/i);
my $page_title = $_;
if ($string =~ /<title>(.*?)<\/title>/is)
{
$page_title = $1;
}
print "<li><a href=\"$File::Find::name\">$page_title</a></li>\n";
},
'/home/ksaund01/public_html');
print "</ol>\n";
print end_html();
End
Were am I going wrong, any help is most appreciated.
(e-mail address removed)