Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

How can I grab all CGI variables at once? (was: CGI)

by Anonymous Monk
on Jul 06, 2001 at 01:55 UTC ( #94303=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I'm new to Perl and I need help with something I'm sure is simple for you veterans. I'm playing with CGI.pm and I can't figure out how to grab all the fieldnames and values off a form at once. I can get at them individually with $q->param('field') but there are over 25 fields and I want to get them all at once.

Edited 2001/07/07 by Ovid

Comment on How can I grab all CGI variables at once? (was: CGI)
Download Code
Re: CGI
by tachyon (Chancellor) on Jul 06, 2001 at 02:04 UTC

    Rather than just give you the answer could I direct you to this tutorial I wrote CGI Help Guide. In it you will find a link to CGI.pm If you follow this link you will get to the official CGI.pm documentation where you will find your question answered under the heading "Fetching The Names Of All The Parameters Passed To Your Script..."

    You may find both the tutorial and the CGI.pm documentation helpful.

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Re: CGI
by PrakashK (Pilgrim) on Jul 06, 2001 at 02:06 UTC
    From the documentation of CGI:
    FETCHING THE NAMES OF ALL THE PARAMETERS PASSED TO YOUR SCRIPT: @names = $query->param; .... FETCHING THE PARAMETER LIST AS A HASH: $params = $q->Vars; print $params->{'address'}; @foo = split("\0",$params->{'foo'}); %params = $q->Vars;
    /prakash
Re: How can I grab all CGI variables at once? (was: CGI)
by converter (Priest) on Jul 06, 2001 at 02:12 UTC

    Look at the "FETCHING THE PARAMETER LIST AS A HASH" section in the CGI manpage for details on the use of &CGI::Vars, which returns the entire list of parameters for assignment to a hash.

    Note that this section includes the warning: "When using this, the thing you must watch out for are multivalued CGI parameters."

Re: CGI
by Maestro_007 (Hermit) on Jul 06, 2001 at 02:13 UTC
    If you use param in a list context with no arguments, it will return "the parameter names as a list" (according to this node),

    @list = $q->param();

    This node is a part of the standard distribution of Perl. Also read it by typing perldoc CGI at the prompt.

    There are literally hundreds of documents within a very close reach of this web site that can answer questions like that. I recommend to anyone who is new to Perl that they first familiarize themself with these documents. It may seem daunding at first, but once you get the hang of it, it's much more rewarding to find the answers on your own.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://94303]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (13)
As of 2014-10-30 18:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (208 votes), past polls