Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
We don't bite newbies here... much
 
PerlMonks  

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

by Anonymous Monk
on Jul 05, 2001 at 21:55 UTC ( [id://94303]=perlquestion: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.

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

Replies are listed 'Best First'.
Re: CGI
by tachyon (Chancellor) on Jul 05, 2001 at 22: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 05, 2001 at 22: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 05, 2001 at 22: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 05, 2001 at 22: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
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://94303]
Approved by root
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.