nevermind this post. The thread didn't show me there were any replies on the page before I responded.

I would suggest using the CGI module as well, but if you really want to do it by hand... Here is an extremely messy, but effective way of parsing (not strict BTW):

############
sub getcgi {
############
	read(STDIN, $input, $ENV{'CONTENT_LENGTH'});
	@pairs = split(/&/, $input);
	foreach $pair(@pairs) {

	        ($name, $value) = split(/=/, $pair);
	        $name =~ tr/+/ /;
	        $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
	        $value =~ tr/+/ /;
	        
	        $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
					#$value =~ s/< *(\/*)[^>]*script[^>]*>/<\1scrypt>/ig;
					#$value =~ s/< *(\/*)[^>]*iframe([^>]*)>/\*\1yframe\2\*/ig;
	        $value=~tr/\'/\`/;
	        $input{$name} = $value;
	}
	@vars = split(/&/, $ENV{QUERY_STRING});
	foreach $var(@vars) {
	        ($v,$i) = split(/=/, $var);
	        $v =~ tr/+/ /;
	        $v =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
	        $i =~ tr/+/ /;
	        $i =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
	        $i =~ s/<!--(.|\n)*-->//g;
	        $v =~ tr/\'/\`/;
	        $info{$v} = $i;
	}

	@vars = split(/;\s?/, $ENV{HTTP_COOKIE});
	foreach $var(@vars) {
	        ($v,$i) = split(/=/, $var);
	        $v =~ tr/+/ /;
	        $v =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
	        $i =~ tr/+/ /;
	        $i =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
	        $i =~ s/<!--(.|\n)*-->//g;
	        $v =~ tr/\'/\`/;
	        $cookie{$v} = $i;
	}
}
This article has been dead for over six months. Start a new discussion instead.