[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] CGI



I have this CGI set up on my server (W* 2.0):
#!perl

$| = 1;
if ($ENV{'REQUEST_METHOD'} eq 'POST')
{
				read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
				@pairs = split(/&/, $buffer);
				foreach $pair (@pairs)
				{
					($name, $value) = split(/=/, $pair);
					$value =~ tr/+/ /;
					$value =~
s/%([a-fA-f0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
					$contents{$name} = $value;
					}
}

$category = $contents{'category'};
$catetext = $contents{'catetext'};
$category =~ tr/\t/ /;
$catetext =~ tr/\t/ /;

open( IN , "<classifieds.data");
read FILE,$text,1000000000;
close (IN);

@records = split(/\t/,$text);

if ($category == "None" && $catetext == "") {
$theReply = <<HT_ML;
Content-type:	text/html

<html><head><title>Clarity Connect Classifieds</title></head><body>
You need to enter information to search for, first.<br>category:
$category<br>text: $catetext</body></html>
HT_ML

print $theReply;
print "\n";
exit;
}

$i = 0;
$results = "";
if ($category != "none" && $catetext != "") {
	until ($i++ == $#records) {
		if (($records[$i] =~ /$category/gi) && ($records[$i] =~
/$catetext/gi)) {$results .= "$records[$i]\n";}
	}
}

if ($category != "none" && $catetext == "") {
	until ($i++ == $#records) {
		if ($records[$i] =~ /$category/gi) {$results .=
"$records[$i]\n";}
	}
}

if ($category == "none") {
	until ($i++ == $#records) {
		if ($records[$i] =~ /$catetext/gi) {$results .=
"$records[$i]\n";}
	}
}

$theReply = <<HT_ML;
Content-type:	text/html

<html><head><title>Clarity Connect Online Classifieds</title></head><body>
Your search results:<br><br>
$records</body></html>
HT_ML

print $theReply;
print "\n";

and I'm getting this response:

You need to enter information to search for, first.
category: Other
text: stuff

Which is impossible, to my mind, because in order to get that message,
category and text BOTH have to be different than what they are.

Any ideas?

-Seraph



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch