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

Mikhael Goikhman migo at homemail.com
Tue Apr 8 15:44:07 PDT 2008


On 08 Apr 2008 21:48:15 +0300, Ran Eilam wrote:
> 
> 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.

Actually setting new value using "param" or deleting it using "Delete"
does affect CGI methods building form elements, i.e. "textfield",
"popup_menu", "hidden" and all others.

(Whether this helps Shmuel or not is another question. It may help, if
for example, to add in his quoted code one line "print hidden($key);" and
to do it inside start_form/end_form.)

> 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.

Regards,
Mikhael.

-- 
perl -e 'print+chr(64+hex)for+split//,d9b815c07f9b8d1e'



More information about the Perl mailing list