#! /usr/bin/perl
# Written by: David J. Kaplan
#       Date: November 14, 1994
print "Content-type: text/plain\n\n"; #inform server what's comming

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); # get the variable=value pairs
@pairs = split(/&/, $buffer); # split multiple pairs to an array
foreach $pair (@pairs) { # need to split each variable=value pair into $name and $value
 ($name, $value) = split(/=/, $pair);
 $value =~ tr/+/ /;
 $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
 if ($name = "searchString") { # we only want the searchString, so find it
    $search_string = $value;
 }
}
system "grep -i $search_string *.pl > artstemp.trash"; #go find the files
print "<HEAD><TITLE>Search Response of /envirolink/cgi-bin</TITLE>";
print "</HEAD><BODY>\n";
print "<H1>This is the response to your query</H1>\n";
print "<B>Search String:</B> <I>$search_string</I><BR>\n";
print "<pre><BR>\n";
open (THE_FILE, "artstemp.trash");
while (<THE_FILE>) { # replace special characters and print the stuff
   $_ =~ s/&/&amp;/g;
   $_ =~ s/</&lt\;/g;
   $_ =~ s/>/&gt\;/g;
   print "$_";
}
print "</PRE></BODY><BR>\n";
system "rm artstemp.trash";