[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Maybe I missed this (fwd)



According to Ron Northrip:
> 
> I have not found any references to this problem so I'm hoping someone
> else has run into this and can help me out. Thanks in advance.

Well, there are a couple of things you can do:

1. Use CGI.pm which covers these problems within it's program.

or 

2. You can do the following:  (Which is what CGI.pm does)

#
#   Routine to get the incoming information
#
sub getInfo
{
    local( $theString, @theInfo );

    if( $ENV{'REQUEST_METHOD'} eq "POST" ){
#
#   Posted information is always treated as a Unix call
#
        $theString = <STDIN>;
        }
        elsif( $ENV{'REQUEST_METHOD'} eq "GET" ){
            $theString = $ENV{'QUERY_STRING'};
            }
        else {
            $theReply = <<HTML_HEADER;
Content-type: text/html

<html>
<head>
<title>
Edit Program Screen
</title>
</head>

<body text=#DDDDDD link=#008800 vlink=#880000 bgcolor=#440000>
<font color=#FFFF00>
<center><b>Could not determine the request method - aborting.</b></center>
</font>
</body>
</html>
HTML_HEADER

            print $theReply;
            exit( 0 );
            }

    $theString =~ tr/+/ /;
    @theInfo = split( /&/, $theString );
    foreach( @theInfo ){
        s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
        s/~!/ ~#/g;
        s/\;/\_/g;
        }

    return( @theInfo );
}

Notice that it is the REQUEST_METHOD which returns POST or
GET.  The QUERY_STRING is just the returning string and, if
the incoming information is not a GET, the information is
stored in the STDIN or standard input area.

But I still say you should learn to use the CGI.pm functions.  :-)

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch