Web form element names automatically become script variable names and are
assigned their values...

use CGI 'param';

for $name (param()) {
        $$name = param($name);
}

The double $$ is not a typo.  Your question resulting in this solution has
reduced the script I'm working on, by about 2000 bytes, or about 3%.  Thank
you.

Gary

Or if you prefer:

use CGI 'param';
$$_ = param($_) for (param());

An amazing little line, all parsing and creation of variables.

If you have multiples, you'll have to tweak it.

> -----Original Message-----
> From: Mariusz [mailto:[EMAIL PROTECTED]]
> Sent: Friday, March 15, 2002 3:23 PM
> To: perl
> Subject: param function
>
>
> hi,
> I have a html form with over 100 fields, is there a quick way to
> assign them in the way that the scalar name becomes the name of the
> field and the value of the field is being assigned to that scalar? I
> know I can just type it one by one:
> $name = param('name');
> $lastname = param('lastname');
> $age = param('age'); ...
>
> , but there must a prettier way to do it:) I was thinking:
>
> @keys = param();
> foreach $key (@keys){
>     my $value = param($key);
> }
>
> but that would run through the loop and leave me only with one last
> pair of retreived $value = "last_field_from_my_form" that I could
> refer to later in my script. However, I need all of the pairs.
>
> Thanks for help.
>
> Mariusz
>
> PS. By the way, this is a great list, you guys are very helpful and
> newbies like me really appreciate what you do.
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to