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

[MacPerl] Environment Variables (fwd)



According to Len:
> 
> How does one transfer variable key/value pairs from HTML on a web page to
> MacPerl ?

#
#   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 );
}

But then - you could also use CGI.pm.

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