At 03:39 PM 5/24/01 -0500, Nichole Bialczyk wrote:
>i just started learning perl about 2 days ago and i'm trying to work my
>way through a tutorial and it is just impossible to get this to work. the
>same thing happened with a similair script, but i dismissed it as a
>fluke. even the helpdesk on campus can't figure it out. any ideas?

Well, we could take severe issue with the approach used by the tutorial 
(roll-your-own CGI processing instead of using CGI.pm, no -w or use strict) 
but there's nothing wrong with the script below.  I pasted it into a CGI 
program and pointed a form at it, it works.  Only thing is, it only handles 
POST requests, not GETs.

>thanks, nichole
>
>#!/usr/bin/perl
>
>print "Content-type:text/html\n\n";
>
>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;
>     $FORM{$name} = $value;
>}
>
>print "<html><head><title>Form Output</title></head><body>";
>print "<h2>Results from FORM post</h2>\n";
>
>foreach $key (keys(%FORM)) {
>     print "$key = $FORM{$key}<br>";
>}
>
>print "</body></html>";

--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com

Reply via email to