Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: CGI - How to use upload_hook and query the query string ?

by ikegami (Patriarch)
on Feb 07, 2006 at 18:22 UTC ( [id://528586]=note: print w/replies, xml ) Need Help??


in reply to CGI - How to use upload_hook and query the query string ?

The hook needs to be called when the request is being parsed (i.e. in new), and the request needs to be parsed in order to know what parameters were supplied. .

Fortunately, the QUERY_STRING is parsed before the body is parsed, so you can use param to check parameters from the QUERY_STRING inside of your hook. Unforunately, the CGI request is not passed to the hook, so you'll have to store the CGI request in a "global":

my $cgi; sub hook { return if not $cgi->param(...); my (...) = @_; ... } $cgi = CGI->new(\&hook);

Replies are listed 'Best First'.
Re^2: CGI - How to use upload_hook and query the query string ?
by cees (Curate) on Feb 07, 2006 at 21:56 UTC

    I thought that by default CGI.pm did not parse the QUERY_STRING if it was a POST request... You actually have to edit the code to get it to parse and combine both the GET and POST parameters together.

    Search the source for CGI.pm for the string "Some people want to have their cake and eat it too".

      Your right. I looked at the source, but I looked too quickly and mistook something else for the parsing of QUERY_STRING. They'll have to modify their CGI.pm or use my alternate solution.
        I've gone down the route of putting the parameters in the URL action of the form as simple query paramaters which seems to work just fine. Many thanks for all the suggestions.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://528586]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-12-07 23:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which IDE have you been most impressed by?













    Results (50 votes). Check out past polls.