salazar has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I seem to have come across a curious nature of the CGI module. When I go to look up parameters, it seems to fail when there are both GET and POST parameters. It reads GET variables fine when nothing is POST'd, but when something is, all the GET variables go away.

Any ideas? Thanks.

Update:
Wow, my fault. This was a question better left unasked, seeing as a quick trip to CGI.pm's documentation solves it.
The param() method will always return the contents of the POSTed fill-out form, ignoring the URL's query string.
Apparently the only reason why my initial code (without POSTed data) must have been some undocumented behavior designed to bugcatch.

Thanks for the help.

Replies are listed 'Best First'.
Re: CGI Parameters
by moritz (Cardinal) on May 19, 2009 at 17:42 UTC
    If you want to query parameters passed in the URL, use url_param.

    Update: as an explanation of the behavior you're seeing: CGI.pm looks into the URL for GET requests and into STDIN for POST requests. url_param will always look into the URL.

      Ok... but that still doesn't explain why using import_params brings in GET variables only when there is nothing POST'd.
        Maybe you could enlighten me as to what import_params is? I don't see it in the docs, so I guess it's not part of the official distribution.

        If it's something you wrote, maybe post it here?