Accessing all CGI input parameters via loop ?

B

- Bob -

Perl newbie question:

I need a little loop that will let me access all of the input
parameters from an HTML form in a generic way without knowledge of the
specific variable (html form field) names.

I know how to do this: my $name = (param("name"));

But, when I don't know the field names, how do I access the structure
of the param's with an index or other non-field-specific technique?

Code snippet appreciated, like I said "newbie" :)

Thanks,
 
P

Paul Lalli

Perl newbie question:

I need a little loop that will let me access all of the input
parameters from an HTML form in a generic way without knowledge of the
specific variable (html form field) names.

I know how to do this: my $name = (param("name"));

But, when I don't know the field names, how do I access the structure
of the param's with an index or other non-field-specific technique?

Code snippet appreciated, like I said "newbie" :)

You don't need a loop for this. But if you really wanted to:
my %value_of;
for my $input (param()) {
$value_of{$input} = param($input);
}

Like I said, you don't need the loop for this, because CGI.pm comes
with a way to generate this hash:

my $value_of_ref = Vars();

Or you could even just import them all into a bunch of package
variables:

import_names('R');
print "$R::name, $R::value, $R::age\n"; #etc

Have another read of
perldoc CGI
There are a lot of options that you may not be aware of yet.

Paul Lalli
 
B

- Bob -

You don't need a loop for this.

I still have a more traditional programming mindset :)
But if you really wanted to:
my %value_of;
for my $input (param()) {
$value_of{$input} = param($input);
}

Thanks, that got me started.
Have another read of
perldoc CGI
There are a lot of options that you may not be aware of yet.

Will do... thanks for the jumpstart.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top