Jason Minton
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?
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?
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.).
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.).
ASKER
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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();
use CGI qw/standard keywords/;
@keywords = keywords();
Sorry, my mistake. ozo was correct.
ASKER
Thanks Tintin for your time and Ozo for the answer... :)
my $query = new CGI;
my @keywords = $query->keywords;