home  CODE LIBRARY  : Perl Form and Query String Parse 
Web and Email Hosting
More Information about our Web and Email Hosting Solution. Linux Web HostingWindows

Parse Form and Query String:

The following splits up the POST and QUERY strings into hashes:

my (%POST, %QUERY);
if ($ENV{GATEWAY_INTERFACE}) {
local *urlsplit = sub {
my %m = ();
foreach my $i (split($_[0], $_[1])) {
my ($k, $v) = (split(/=/, $i, 2));
$k =~ y/+/ /; $v =~ y/+/ /;
$k =~ s/\%([a-fA-F0-9]{2})/pack('C', hex($1))/seg;
$v =~ s/\%([a-fA-F0-9]{2})/pack('C', hex($1))/seg;
$m{$k} = $v;
}
return (%m);
};

if ($ENV{REQUEST_METHOD} eq 'POST' &&
$ENV{CONTENT_TYPE eq 'application/x-www-form-urlencoded') {
my $line;
my $dos = $ENV{CONTENT_LENGTH};
if ($dos > 0x100000) {
$dos = 0x100000;
}
read(STDIN, $line, $dos);
%POST = &urlsplit('&', $line);
}
%QUERY = &urlsplit('[&;]', $ENV{QUERY_STRING});
}

Email and Web Hosting by Internet Connection 2004-2007 ©
Contact IC Support via AIM!  Our SN is ICSupportDesk