Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieve all params from cgi module

Status
Not open for further replies.

MatthewP

Programmer
Jan 16, 2001
176
GB
Hi,

Using the CGI module, how can I retrieve all of the params that have been passed through a form into the program if I don't know what they're called. ie - I know I can do

print "$q->param('my_fieldname')\n";

but if I don't know what the field names are, how can I loop through them as if it were a hash like

foreach $key (keys %ALL_PARAMATERS){
print "$key - $ALL_PARAMATERS{$key}\n";
}

Thanks,
Matt.
 
You can do this:
Code:
my %params = $q->Vars;

Be careful using this if a parameter name can have more than one value (like a checkbox group for example).
Read more here: under the heading "Fetching the Parameter List as a Hash"
 
Alternatively,
Code:
my @param_names = $q->param;
#and then
print "$_ - ",$q->param($_),"\n" for @param_names;

Apologies for the extra post - forgot this method earlier.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top