Sorry, forgot the code ;)

To the Plethora Of Perl Programmers (P.O.P.P), I seek your guidance.
First of all, can you tell me what is wrong with this script other than
neglecting to “use strict”.  (I’m learning)
            From the command prompt, it says:

Syntax error near  $ENV{'REQUEST_METHOD')
…Aborted due to compilation errors

            Script follows:
#!c:/perl/bin/perl -w

if ($ENV{'REQUEST_METHOD') eq 'GET')
            {
  @pairs = split (/&/,
    $ENV{'QUERY_STRING'});
}  elsif ($ENV{'REQUEST_METHOD'} eq
  'POST') {
  read (STDIN, $buffer,
            $ENV{'CONTENT_LENGTH'});
  @pairs = split(/&/, $buffer);
} else {
  print "Content-type: text/html\n\n";
  print header;
  print "<P>Use Post or Get";
}

foreach $pair (@pairs) {
  ($key, $value) = split (/=/, $pair);
  $key =~ tr/+/ /;
  $key =~ s/%([a-fA-F0-9] [a-fA-F0-9])/
            pack("C", hex($1))/eg;
  $value =~ tr/+/ /;
  $value =~s/%[a-fA-F0-9] [a-fA-F0-9])/
            pack("C", hex($1))/eg;

  $value =~s/<!--(.|\n)*-->//g;

  if ($formdata{$key}) {
            $formdata{$key} .= ", $value";
  } else {
            $formdata{$key} = $value;
  }
}

print "Content-type: text/html\n\n";
print header;
foreach $key (sort keys(%formdata)) {
  print "<P>The field named<B>$key</B> contained <B>$formdata{$key}</B>";
}


I’m trying to parse a form I made on my win98 box w/ apache and activestate
perl.

Also, when I try to run the script from my submit button on the HTML form, I
get:

“The page cannot be found”

I thought that maybe the problem was in the httpd.conf file in apache, but I
have since read the Apache docs on server configuration and feel that I have
the permissions and related declarations all straightened out.
So my question is:  Is the problem with my script or what?
Also, is there a better way to parse forms?  I’ve been told to use CGI.pm,
but I don’t know how to “invoke” it. Any good docs to read on it?
Thanks for your help,
Nathan
www.tandrtrailer.com <http://www.tandrtrailer.com/>
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>

Reply via email to