Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Accessing all CGI input parameters via loop ?

Reply
Thread Tools

Accessing all CGI input parameters via loop ?

 
 
- Bob -
Guest
Posts: n/a
 
      03-23-2007
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,
 
Reply With Quote
 
 
 
 
Paul Lalli
Guest
Posts: n/a
 
      03-23-2007
On Mar 23, 8:03 am, - Bob - <uctra...@ultranet.com> wrote:
> 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

 
Reply With Quote
 
 
 
 
- Bob -
Guest
Posts: n/a
 
      03-23-2007
On 23 Mar 2007 06:34:12 -0700, "Paul Lalli" <> wrote:


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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Triple nested loop python (While loop insde of for loop inside ofwhile loop) Isaac Won Python 9 03-04-2013 10:08 AM
How to execute a break in a loop via user input Thomas Wilson Ruby 3 10-14-2009 08:36 AM
I have just creted a loop to sort integers in the input loop who's it Anshu C++ 5 08-14-2006 03:13 PM
Python CGI - Accepting Input, Invoking Another Process, Ending CGI LarsenMTL Python 4 11-04-2004 05:59 PM
pass all cgi parameters to an exe D Perl Misc 3 07-24-2003 01:35 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57