#!/usr/local/bin/perl54

# ===== HTML setup ======
print "Content-type: text/html\n\n";
print "\n";
# ===== HTML setup ======
print"<html>";
print "hello</html>";
&formParse;
exit;
sub formParse
{

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