use CGI qw/:standard/; $terms = param(terms); $baseurl = 'http://www.lipscher.com/seth/'; $title = "Seth's Home Search Results"; $sitename = "Seth's Home"; $title_url = 'http://www.lipscher.com/seth'; $search_url = 'http://www.lipscher.com/seth'; # Get Files To Search Through &get_files; # Search the files &search; # Print Results of Search &return_html; sub get_files { chdir("e:\\seth"); @dirs = `dir /B`; foreach $folder (@dirs) { chomp($folder); if (-d "$folder") { @ls = `dir /B $folder\\*.htm`; foreach $temp_file (@ls) { chomp($temp_file); push(@FILES,"$folder/$temp_file"); } } else { if ($folder =~ /.htm/i) { push(@FILES,"$folder"); } } } } sub search { chdir("e:\\seth"); @terms = split(/\s+/, $terms); foreach $FILE (@FILES) { open(FILE,"$FILE"); @LINES = ; close(FILE); $string = join(' ',@LINES); $string =~ s/\n//g; foreach $term (@terms) { if (!($string =~ /$term/i)) { $include{$FILE} = 'no'; last; } else { $include{$FILE} = 'yes'; } if ($string =~ /(.*)<\/title>/i) { $titles{$FILE} = "$1"; } else { $titles{$FILE} = "$FILE"; } } } } sub return_html { print "Content-type: text/html\n\n"; print "<html>\n <head>\n <title>Results of Search\n \n"; print "\n \n

"; print "

$title

\n
\n"; print "Below are the results of your Search in no particular order:


\n"; print "



\n"; # print "

\n"; print "
\n"; print "\n\n"; }