#!/usr/bin/perl # readenv.cgi -- reads the environment, argv, and stdin # the first line of this script may have to be changed # if your system's Perl interpreter is not located in /usr/bin/perl # Written by P. Lutus 2/21/96 lutusp@arachnoid.com print "Content-type:text/html\n\n
";

print ("Environment Entries:\n"); # there are always some of these!
foreach $n (keys %ENV) {
	print ("\t$n=$ENV{$n}\n");
}

if ($ARGV[0]) {
	print ("Command-line Arguments:\n");
	foreach $n (@ARGV) {
		print ("\t$n\n");
	}
}

if($ENV{'CONTENT_LENGTH'}) {
		if($ENV{'CONTENT_LENGTH'} > 0) {
			read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
		print ("Stdin Contents:\n");
		print "\tRaw form: $buffer\n\n";
		print "\tFormatted:\n\n";
		@pairs = split(/&/, $buffer);
		foreach $pair (@pairs) {
			($name, $value) = split(/=/, $pair);
			$name =~ tr/+/ /;
			$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
			$name =~ s/~!/ ~!/g; # Stop people from using subshells to execute commands
			$value =~ tr/+/ /;
			$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
			$value =~ s/~!/ ~!/g; # Stop people from using subshells to execute commands
			print "\t\t$name = $value\n";
		}
	}
}

print "
"