Un-webifying HTML User Data Question

[email protected] ("Gregory Smith") Thu, 10 May 2001 06:46:34 -0700
Newsgroups perl.macperl.webcgi
Message-ID <[email protected]>
Hello,

Sorry if this issue has been beaten into the ground before.  I looked
through the webcgi archives and didn't see anything that I thought could
help me here.

I'm wondering if one of you kind folks could point me to how to "un-webify"
data passed from an HTML form for use in a MacPerl CGI?  My Perl/CGI
experience is with *nix CGI scripts.  When I attempt to run my "un-webify"
code under MacPerl with a WebStar Server, MacPerl crashes.  The test code
below and HTML form run fine on my *nix box.  I CAN get a simple "Hello
World" CGI to run on the WebStar server so I know that at least the base
install of MacPerl is functioning.

I don't seem to be able to find specific information regarding this issue.
I have MacPerl: Power And Ease and have read the short chapter on CGI
scripts.

I would be greatly appreciate if anyone could point out what I'm doing wrong
or where to look for specific information.

So far I have my "real" script running fine locally.  So I know the base
code does what I want it to do. I just can't seem to get the user data
passed to the CGI from the HTML form page.

Here's a test script using my usual  *nix "un-webify" code which will crash
or freeze MacPerl on my WebStar server:
-=-=-=-=-=-=-=-=-=-=-

#!perl -w
use CGI;
my($cgi) = new CGI;

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
   ($name, $value) = split(/=/, $pair);
   $value =~ tr/+/ /;
   $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
   $value =~ s/<!--(.|\n)*-->//g;
   $FORM{$name} = $value;
}

print $cgi->header();
print "Hello $FORM{'real_name'}\n\n"; # Print user data
print "$ENV{'CONTENT_LENGTH'}\n";     # Print string passed from HTML form
0;

-=-=-=-=-=-=-=-=-=-=-

At this point, I'm just trying to pass the data from the HTML form to the
CGI and then simply printing out the data back to the browser.

Thanks for your help!
--

Thanks,
Greg Smith