[Israel.pm] CGI::param - setting values

Ran Eilam ran.eilam at gmail.com
Tue Apr 8 11:48:15 PDT 2008


Hey Shmuel!

On Mon, Apr 7, 2008 at 11:32 PM, Shmuel Fomberg <semuelf at 012.net.il> wrote:
>  I'm thinking on getting all the supplied parameters, decode them, and
>  then set them back.

>  foreach my $key ($q->param) {
>    my $new_value = decode("...", $q->param($key));
>    $q->param($key, $new_value);

>  (assuming that I don't create a form in the outgoing page using CGI.pm
>  functions)

1) If there is no form, the parameters could only live in cookies or
links, which I assume you are not creating either, so these parameters
will NOT appear in the next HTTP request, which is what I assume you
mean when you say "then set them back".

2) From the CGI.pm docs (SETTING THE VALUE(S) OF A NAMED PARAMETER) it
looks like setting parameters does NOT effect the generation of HTML
for the web client. So even if you did create a form/cookie/link,
CGI.pm will NOT set the parameters for you. All it does (did not look
in source or tests, just docs) is change the parameter values for the
current processing of the request.

3) If you need to pass parameters from page to page you need a form
(perhaps hidden), a cookie, or do some link massaging. From the docs,
it looks like CGI.pm has only low level support for this, from
CREATING A HIDDEN FIELD:

"hidden() produces a text field that can't be seen by the user. It is
useful for passing state variable information from one invocation of
the script to the next."

Which implies you have to do it yourself- place the parameters in the
generated forms/links/cookies. Web programming sux.


-- 
 Ran Eilam ran.eilam at gmail.com



More information about the Perl mailing list