Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

post and get

by hotshot (Prior)
on Mar 18, 2002 at 08:13 UTC ( #152422=perlquestion: print w/ replies, xml ) Need Help??
hotshot has asked for the wisdom of the Perl Monks concerning the following question:

Hello guys !

I have a CGI script, and I'v been wanting to know if there's a way to know if a parameter I got from the browser, was sent to me in POST or GET method.



Comment on post and get
Replies are listed 'Best First'.
Re: post and get
by blakem (Monsignor) on Mar 18, 2002 at 08:16 UTC
    Check the value of $ENV{REQUEST_METHOD}


Re: post and get
by busunsl (Vicar) on Mar 18, 2002 at 08:25 UTC
    Use the CGI module and you don't have to bother about the request method.
    But if you need it anyway, use CGI's request_method() function.
Re: post and get
by tomhukins (Curate) on Mar 18, 2002 at 09:53 UTC
Re: post and get
by Juerd (Abbot) on Mar 18, 2002 at 09:53 UTC

    was sent to me in POST or GET method.

    Blake already gave a perfect answer, but I'd like to add that %ENV is loaded with useful information. Give the following piece of code a try to find out more about this wonderful hash.

    use Data::Dumper; print Dumper \%ENV;


Re: post and get
by newrisedesigns (Curate) on Mar 18, 2002 at 22:08 UTC

    Whenever you write something in Perl for use as a CGI application, it's always best to use The module is in almost every distrobution, and it doesn't cause too much of a delay (if speed is your concern.) will also handle your queries for you, and can determine GET from POST and vice-versa.

    All the instructions for use are right here, and I'm sure any monk here will help you if you need it.

    Hope this helps.

    John J Reiser

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://152422]
Approved by root
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2015-11-25 09:41 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (672 votes), past polls