#!/usr/bin/perl5
require "get_form_data.pl";
&get_form_data();
$search_term = $FORM{'search'};
print "Content-type: text/html\n\n";
opendir(DIR, ".");
while($file = readdir(DIR))
{
next if($file !~ /.html/);
open(FILE, $file);
$found_match = 0;
$title = "";
while()
{
if(/$search_term/i)
{
$found_match = 1;
}
if((//) || ($found_title))
{
if((/<\/TITLE>/) && (//)) {
chop;
$title = $_;
$title =~ s///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)
{
print "$title\n";
print "
\n";
}
close(FILE);
}
closedir(DIR);
exit;