Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: How do I get at the parameters in my CGI program?

by icuc (Initiate)
on Aug 02, 2000 at 10:47 UTC ( [id://25670]=note: print w/replies, xml ) Need Help??


in reply to How do I get at the parameters in my CGI program?

As contributed by icuc:
use strict; use CGI; # ..... my $q = new CGI; my %params = {}; { my @params_names = $q->param; for(@params_names) { $params{$_} = $q->param($_); } }

or, a shorter way, as contributed by slayven:

use CGI; my $q = new CGI; my %in = map { $_ => $q->param($_) } $q->param;

Click this Answer to see merlyn's note about $q...

Replies are listed 'Best First'.
RE: Answer: How do I get at the parameters in my CGI program?
by merlyn (Sage) on Aug 02, 2000 at 17:29 UTC
    Lincoln Stein no longer recommends the use of the visible CGI object, simply because the number of CGI objects in a typical program is merely one. Instead, pull in the methods you need as subroutines. If parameter access is all that's required, use:
    use CGI qw(param); ... my $source = param('source'); my @destination_states = param('dest'); # multi-select
    But I typically use
    use CGI qw(:all);
    since I'm also using the HTML generation shortcuts.

    -- Randal L. Schwartz, Perl hacker

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://25670]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-04-25 10:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found