Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Before you reply note that I dont want to use CGI.pm's param function. Just my own

This doesnt seem to be working when I execute my script with index.cgi?boo=a, It will print No

#!/usr/bin/perl #-------------INFO---------------# ## Matrix 1.0 ## Author: Andrew Rosolino ## Site: http://www.webewebin.com #-------------START--------------# ## Load Modules use CGI::Carp "fatalsToBrowser"; use DBI; &ReadParse; print "Content-type: text/html\n\n"; if($in{'boo'}) { print "Yea"; } else { print "No"; } ### Read Parse sub ReadParse { local (*in) = @_ if @_; local ($i, $key, $val); # Read in text read(STDIN,$in,$ENV{'CONTENT_LENGTH'}); @in = split(/[&;]/,$in); foreach $i (0 .. $#in) { # Convert plus's to spaces $in[$i] =~ s/\+/ /g; # Split into key and value. ($key, $val) = split(/=/,$in[$i],2); # splits on the first =. # Convert %XX from hex numbers to alphanumeric $key =~ s/%(..)/pack("c",hex($1))/ge; $val =~ s/%(..)/pack("c",hex($1))/ge; # Associate key and value $in{$key} = $val; } }

Shouldnt that be printing yes?

Replies are listed 'Best First'.
Re: My parsing not working
by iburrell (Chaplain) on Nov 02, 2002 at 00:34 UTC
    It doesn't work because you are reading the parameters for a POST but are using a GET URL. For a GET URL, The server passes the request string (everything after the question mark) in the QUERY_STRING environment variable. For a POST, the parameters are passed in the same format on stdin but only with Content-Type application/x-url-encoded.
Re: My parsing not working
by Thelonius (Priest) on Nov 02, 2002 at 00:37 UTC
    This doesnt seem to be working when I execute my script with index.cgi?boo=a, It will print No
    That's because "boo=a" is in the environment variable QUERY_STRING and not to be read from STDIN.
Re: My parsing not working
by Louis_Wu (Chaplain) on Nov 02, 2002 at 00:12 UTC
    Could you tell us why you don't want to use CGI's params? Is there an issue with local admins or machines? Did you have a bad experience as a child?