How do I request Querystring in CGI (eg I want to get the string 'thedata' from www.website.com/test.pl?thedata=bob)
Printable View
How do I request Querystring in CGI (eg I want to get the string 'thedata' from www.website.com/test.pl?thedata=bob)
by calling this sub below, when the script is first executed it will place any querys into an array.
ie.. for your example it would be,
#ie.. thedata would equal bobCode:parse_form;
$thedata = $input{'thedata'};
(the parse form sub that is called,
Code:sub parse_form {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
if (length($buffer) < 5) {
$buffer = $ENV{QUERY_STRING};
}
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$input{$name} = $value;
}
}