Link to home
Start Free TrialLog in
Avatar of Jason Minton
Jason MintonFlag for United States of America

asked on

Perl CGI: list post/get param keys

perl cgi question:

How do I get a list of defined cgi params from a post/get?

Let's say param('name'), param('address') are defined.

How can I get a list of those names (name, address) without knowing they exist?
Avatar of Tintin
Tintin

use CGI;
my $query = new CGI;
my @keywords = $query->keywords;
Avatar of Jason Minton

ASKER

hmm...

That doesn't seem to return anything.

You see, I'm calling a logging sub from another sub that is doing some stuff and at this point there are several keywords defined already, but I never issued a new CGI; anywhere... i'm just 'use' ing CGI qw/standard/;.  So there are params, like param('blah') and param('blahblah'), but from this logging sub, I want a list of all those keywords (blah, blahblah, etc.).
i modified the script so it sets a $var = new CGI; and then i reference all the params as $var->param('blah');  However, still i get nothing returned into @keywords for $var->keywords;.
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
OK, so you're using the function interface to the CGI module rather than OO.  In that case, do

use CGI qw/standard keywords/;
@keywords = keywords();
Sorry, my mistake.  ozo was correct.
Thanks Tintin for your time and Ozo for the answer... :)