|
Get variables from QUERY_STRING
if
(
$ENV
{
'REQUEST_METHOD'
}
eq
"GET"
)
{
$qstring
=
$ENV
{
'QUERY_STRING'
}
;
}
else
{
$qstring
=
<
STDIN
>
;
# read(STDIN, $qstring, $ENV{'CONTENT_LENGTH'});
}
@pairs
=
split
(/&/,
$qstring
);
# split the name-value pairs
foreach
$pair
(
@pairs
)
# loop through each pair
{
(
$name
,
$value
)
=
split
(/=/,
$pair
);
# Create a Name/Value pair set
$name
=
~
tr
/a-z/A-Z/;
# make keys uppercase (optional)
$value
=
~
s
/\+/
/
g;
# change + signs to spaces
$value
=
~
tr
/+/
/
;
# change + signs to spaces (alternate)
$value
=
~
s
/%(..)/pack("c",hex($1))/
ge
;
# convert the URI code
$in
{
$name
}
=
$value
;
# put in hash array %in
}
print
%in
|