From a recent comp.infosystems.www.authoring.cgi post:
And the horror doesn't stop there, but I wanted to minimize your exposure. This is 2006, right?sub ParseForm { my ($key, $prefs, $buffer); if ($ENV{'REQUEST_METHOD'} eq 'GET') { @pairs = split(/&/, $ENV{'QUERY_STRING'}) } elsif ($ENV{'REQUEST_METHOD'} eq 'POST') { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer) } else {Error('Bad or Unknown Request Method', "The form's request method must be either 'POST' or 'GET'. Please check your HTML.")}
foreach $pair (@pairs) { local($name, $value) = split(/=/, $pair); $name =~ tr/+/ /; $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s///mg; $FORM{$name} = $value; ...
Obviously CGI.pm can do a lot more, but that's enough to get you started.use CGI;
my $cgi = CGI->new();
my $foo_param = $cgi->param('foo');
my $bar_param = $cgi->param{'bar');