<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<META content="MSHTML 6.00.5730.11" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT size=2>Hi All,</FONT></DIV>
<DIV><FONT size=2>I have a quick question.</FONT></DIV>
<DIV><FONT size=2>I'm using "opendir" and trying to get my search.cgi script to
search in my main www directory instead of my cgi-bin </FONT></DIV>
<DIV><FONT size=2>as the HTML pages found can't be accessed there.</FONT></DIV>
<DIV><FONT size=2>I did this as a tutorial from a book I have.</FONT></DIV>
<DIV><FONT size=2>Here are my Env Variables:</FONT></DIV>
<DIV><FONT size=2><A
href="http://www.autotection.com/cgi-bin/env_var.pl">http://www.autotection.com/cgi-bin/env_var.pl</A></FONT></DIV>
<DIV><FONT size=2>any help very appreciated.</FONT></DIV>
<DIV><FONT size=2>Thanks Steve</FONT></DIV>
<DIV><FONT size=2>############search.cgi</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>#!/usr/bin/perl<BR>&get_form_data();<BR>$search_term =
$FORM{'search'};<BR>print "Content-type:
text/html\n\n";<BR>&search(".");</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2>sub get_form_data<BR> {<BR> # get the
data<BR>read(STDIN, $buffer, $ENV{ 'CONTENT_LENGTH' } );</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2>@pairs = split(/&/, $buffer);<BR>foreach $pair
(@pairs)<BR>{<BR> ($firstname, $value) = split(/=/, $pair);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2> $value =~ tr/+/ /;<BR> $value =~
s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;<BR> $value =~
s/<!--(.|\n)*-->//g;<BR> $FORM{$firstname} = $value;<BR>
}<BR>}</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2>print
<<EOF;<BR><HTML><BR><HEAD><BR><TITLE><BR>Search<BR></TITLE><BR></HEAD></FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2><BODY BGCOLOR="#FFFFFF"><BR><P>Results of your
search: $search_term</P><BR>EOF<BR>foreach $file
(@found_set)<BR>{<BR> print "<A
HREF=\"$file\">$Title{$file}</A>\n";<BR> print
"<BR>\n";<BR>}<BR>if ((@found_set) != "") {<BR> print
"<H3>Above Are Matches for the Search Term:
$search_term</H3>\n";<BR>} else {<BR> print "<H3>Sorry, no
files found under the search term: $search_term</H3>\n";<BR>}</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2>print
<<EOF;<BR></BODY><BR></HTML><BR>EOF<BR>exit;<BR>sub
search<BR>{<BR> local ($dir) = @_;<BR> if($dir eq
".")<BR> {<BR> opendir(DIR, ".");<BR> $dir =
"";<BR> }<BR> else<BR> {<BR> opendir(DIR,
$dir);<BR> $dir .= "/";<BR> }<BR> foreach $file (sort
readdir(DIR))<BR> {<BR> next if($file eq "." || $file eq
"..");<BR> $file = $dir . $file;<BR> next if(($file !~
/.htm/) && (!(-d $file)));</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2> if(-d
$file)<BR> {<BR> &search($file);<BR> next;<BR> }<BR> open(FILE,
$file);<BR> $found_match = 0;<BR> $title =
"";<BR> while(<FILE>)<BR> {<BR> if(/$search_term/i)<BR> {<BR> $found_match
=
1;<BR> }<BR> if(/<TITLE>/)<BR> {<BR> chop;<BR> $title
= $_;<BR> $title =~
s/<TITLE>//g;<BR> $title =~
s/<\/TITLE>//g;<BR> }<BR> }<BR> if($found_match)<BR> {<BR> push(@found_set,
$file);<BR> if($title eq
"")<BR> {<BR> $Title{$file} =
$file;<BR> }<BR> else<BR> {<BR> $Title{$file}
=
$title;<BR> }<BR> }<BR> close(FILE);<BR> print
"<P>\n";<BR> }<BR> closedir(DIR);<BR>}</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2></FONT> </DIV></BODY></HTML>