Perl CGI no longer used?

R

Raphael Wegmann

Jürgen Exner said:
Bush is a Fascist wrote:
Hi Bush




What is "it"? Please quote some context such that people have a chance to
know what you are talking about.




Which manual approach? What split and foreach loop?
Do you mind explaining what you are talking about?

Maybe he means something like this:

my ($string,$param,$value,%args);

if ($ENV{'REQUEST_METHOD'} eq 'POST') {
read(STDIN,$string, $ENV{'CONTENT_LENGTH'});
} else {
$string = $ENV{'QUERY_STRING'} if defined $ENV{'QUERY_STRING'};
}

foreach (split(/[&;]/,$string)) {
tr/+/ /;
s/%([0-9a-fA-F]{2})/chr(hex($1))/ge;

($param,$value) = split('=',$_,2);
if (exists $args{$param}) {

# this part is needed, if you have something like
# selected=1&selected=2&selected=3 in your url
if (ref($args{$param}) eq 'ARRAY') {
$args{$param} = [ @{$args{$param}} , $value ];
} else {
$args{$param} = [ $args{$param} , $value ];
}

} else {
$args{$param} = $value;
}
}


There are probably more elegent ways to parse the url-parameters,
but it works for me and is smaller than CGI.pm,
esp. if you don't need all the html-print-functions.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top