Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: Unwanted parameter when executing CGI scripts

by Nocturnus (Sexton)
on Jan 05, 2013 at 08:01 UTC ( #1011762=note: print w/ replies, xml ) Need Help??


in reply to Re: Unwanted parameter when executing CGI scripts
in thread [SOLVED] Unwanted parameter when executing CGI scripts

Well, I think that

$q->delete('keywords') if $q->keywords;

will delete the "keywords" parameter in every case, i.e. regardless if it has been automatically generated by CGI.pm or if it actually has been passed via query string. But as I wrote in my initial post, I would like to remove it only in the former case (for example when the script has been called without any parameters), but I want to keep it if it has been "actively" passed via query string.

Thus, I think I really have to check if there is no query string, or if there is a query string which does not contain = or &, and remove the "keywords" parameter accordingly.

Anyways, thank you very much for your suggestion. I have learned a much from how you use dd and Data::Dump.

Regards,

Nocturnus


Comment on Re^2: Unwanted parameter when executing CGI scripts
Download Code
Re^3: Unwanted parameter when executing CGI scripts
by Anonymous Monk on Jan 05, 2013 at 09:19 UTC

    will delete the "keywords" parameter in every case, i.e. regardless if it has been automatically generated by CGI.pm

    You're wrong :)

    I didn't read past that statement, but if you need convincing you are wrong, read the CGI.pm source

      OK, I am sorry. You are right (no need to read the source code, only the documentation ...).

      Interestingly, the delete method seems to remove the respective entry only from $q->params, but not from $q->url_params (now guess which of the two I (have to) use). This is not documented in the CGI.pm documentation as far as I have seen.

      But that's not a big problem. I just will use one of the usual methods to remove the respective hash entry.

      Besides this, I didn't get your code to work like I want. Perhaps I have another error, but at the moment it seems that $q->keywords is empty if the script is called without any parameters, so $q -> keywords evaluates to false in this case, and the code doesn't get executed anyways.

      Regards,

      Nocturnus

        :D

        Interestingly, the delete method seems to remove the respective entry only from $q->params, but not from $q->url_params (now guess which of the two I (have to) use).

        You know what :) you don't really *have* to :) there are many options, patch CGI.pm, monkeypatch CGI, fix code ....

        Besides this, I didn't get your code to work like I want. Perhaps I have another error, but at the moment it seems that $q->keywords is empty if the script is called without any parameters, so $q -> keywords evaluates to false in this case, and the code doesn't get executed anyways.

        Yeah, if there are no keywords, don't delete keywords -- makes sense to me :)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (9)
As of 2014-10-23 13:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (125 votes), past polls