Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

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.



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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2018-06-20 23:19 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (117 votes). Check out past polls.