Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

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

by icuc (Initiate)
on Aug 02, 2000 at 10:47 UTC ( #25670=categorized answer: print w/replies, xml ) Need Help??

Q&A > CGI programming > How do I get at the parameters in my CGI program? - Answer contributed by icuc

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
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2020-04-08 06:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The most amusing oxymoron is:
















    Results (43 votes). Check out past polls.

    Notices?