Hi All
I'm very new to Perl and was trying to add a simple perl search to my website.
I have a very basic form on my search page, literally just a search box and it is linked to this search.cgi file in my cgi-bin folder.
I have my permissions set to 755, but get an error when I run a search. Here is the script please let me know if you need more information or if you see where I could be going wrong.
Thanks!!!
#!/usr/local/bin/perl
use script;
use CGI qw
standard);
use File::Find;
my $query = param("query");
print header();
print start_html();
print $query;
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;
},
'print "</ol>\n";
print end_html();
End
I'm very new to Perl and was trying to add a simple perl search to my website.
I have a very basic form on my search page, literally just a search box and it is linked to this search.cgi file in my cgi-bin folder.
I have my permissions set to 755, but get an error when I run a search. Here is the script please let me know if you need more information or if you see where I could be going wrong.
Thanks!!!
#!/usr/local/bin/perl
use script;
use CGI qw
use File::Find;
my $query = param("query");
print header();
print start_html();
print $query;
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;
},
'print "</ol>\n";
print end_html();
End