CGI_UltraLite.pm

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#                                                                       #
# CGI_UltraLite.pm                                                      #
#                                                                       #
# Exports functions for parsing GET and POST data.                      #
#                                                                       #
# Provides two variables: a string containing all data, and an array of #
# the various data individually.                                        #
#                                                                       #
# (c) 2000, Benjamin Schak                                              #
# Feel free to use in any way, as long as you keep this notice.         #
#                                                                       #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

package CGI_UltraLite;
require Exporter;

@ISA = qw(Exporter);
@EXPORTS = qw(getparse postparse);

$user_string;
@value;

sub getparse {
	$user_string = $ENV{'QUERY_STRING'};
	my @name_value_pairs = split(/[&;]/, $user_string);
	my $name_value_pair;
	foreach $name_value_pair (@name_value_pairs) {
		my ($keyword, $value) = split(/=/, $name_value_pair);
		$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",
hex($1))/ge;
		push(@value, "$value");
	}
}

sub postparse {
	read (STDIN, $user_string, $ENV{'CONTENT_LENGTH'});
	$user_string =~ s/\+/ /g;
	my @name_value_pairs = split(/[&;]/, $user_string);
	my $name_value_pair;
	foreach $name_value_pair (@name_value_pairs) {
		my ($keyword, $value) = split(/=/, $name_value_pair);
		$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",
hex($1))/ge;
		push(@value, "$value");
	}
}

1;