in reply to $ENV{'REQUEST_METHOD'} undefined?

It seems the script is meant to be run via Common Gateway Interface, but is not.

I highly recommend using the CGI module (or another well-tested CGI module from CPAN) instead of using hand-written routines.

Replies are listed 'Best First'.
Re^2: $ENV{'REQUEST_METHOD'} undefined?
by Lamont85 (Novice) on Nov 30, 2009 at 12:13 UTC

    I don't quite understand. I have updated the code (to the best of my ability) to use the CGI module. Perhaps, I am leaving something out. Keep in mind that the actual script will accept any number of parameters through an HTML form.

    #!C:\Perl\bin\perl.exe use strict; use warnings; use CGI; my $req_meth = CGI->request_method(); sub readPostInput() { my (%searchField, $buffer, $pair, @pairs); if ($req_meth eq 'POST') { read (STDIN,$buffer,$ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); foreach $pair (@pairs) { my ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/e +g; $name =~ tr/+/ /; $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg +; $searchField{ $name } = $value; } } } my %postInputs = readPostInput(); print "Content-type: text/html\n\n"; print "Complete :: $req_meth";

    After these changes I still receive the same error.

      use strict; use warnings; use CGI; my $req_meth = CGI->request_method(); my %postInputs = CGI->Vars; ...

      Still you haven't answered the most important question: Is the script run as a CGI script? That is, is there a web server that executes it with the CGI protocol?

      Perl 6 - links to (nearly) everything that is Perl 6.

        This script, I believe, is not run as a CGI script. I say this because I haven't yet used the CGI module in it. HTML is ouput using templates, and any data is stored into DAT files simply by opening them and writing to them.

        I hope that answers your question.