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

RE>[MacPerl] Environment Va



RE>[MacPerl] Environment Variables
I do it by using the perl script as a cgi.  I think it's the only way to do this because it takes server software to take the request header info and redirect it to your script.  

Use the FORM html tag line in the web page to indicate what Perl script that awaits on the server:

<FORM ACTION="/shell/suggestion_form.pl" METHOD="POST" ENCTYPE="application/x-www-form-urlencoded">

Then in you Perl script you have to use something that is available in many free scrips floating around the net that will split the var/value pairs like this:

### Get the input
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

### Split the name-value pairs
@pairs = split(/&/, $buffer);

foreach $pair (@pairs) {
   ($name, $value) = split(/=/, $pair);

   ### Un-Webify plus signs and %-encoding
   $value =~ tr/+/ /;
   $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
   $value =~ s/<!--(.|\n)*-->//g;

   $FORM{$name} = $value;
 }

I don't have the name of the person the previous code is attributed to, but I do not claim to have written this myself.  You can find this also in Perl books or cgi books.

--------------------------------------
Date: 9/5/97 12:03 AM
To: Paul Linder
From: Len
How does one transfer variable key/value pairs from HTML on a web page to
MacPerl ?

Len



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



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