http://www.perlmonks.org?node_id=1222917


in reply to How to check the request is (GET OR POST) in CGI

It may be surprising to discover this, but unlike some RFCs, the CGI RFC-3875 is readable, and describes the answer to this question.

The one piece of ambiguity on this topic in the RFC is that the meta variables such as REQUEST_METHOD are described in the document as being made available to the system in a "system-defined manner". For webservers I've worked with, they're available as environment variables. Wrappers such as CGI include an accessor for this information. In the case of CGI.pm the accessor is called request_method. And CGI.pm does indeed expect to find REQUEST_METHOD in an environment variable, and looks nowhere else.

In Perl, the environment variables are available through the %ENV global hash. So $ENV{'REQUEST_METHOD'} would have what you're looking for, but if you are using CGI.pm you would probably be making a good choice by using the accessors that module provides (request_method()).


Dave