http://www.perlmonks.org?node_id=656594


in reply to CGI: List all params

If you are using CGI.pm, you can say
my @names = $query->param;
to get the names of all the parameters (and then proceed to fetch the values one by one).

Replies are listed 'Best First'.
Re^2: CGI: List all params
by Anonymous Monk on Mar 01, 2011 at 07:07 UTC
    Could you explain how we can "proceed to fetch the values one by one"? All I can do right now is just get the list of the variables...but I can't actually get their values. Sorry to reply to such an old post. Thank you in advance!
      but I can't actually get their values. Sorry to reply to such an old post. Thank you in advance!

      That is because you skipped the requisite reading step. CGI. Basically, you give param an argument, it returns values.

        my $query = CGI->new; my @names = $query->param; foreach my $name (@names) { print $name . ' => ' . param($name) . "<BR />\n"; } print "<P>\n";
      foreach $name ( @names ) { if ( $name =~ /\_/ ) { next; } else { print "

      ".$name."\t=\t".$query->param($name) . "

      \n"; } some thing like this you can do