Hi Ken, 

Try the following: 

my $q = new CGI;

if (defined $q->param('data')) {
 #
 # data was a parameter... 
 #
}
else {
 #
 # data was not a parameter... 
 #
}

cheers,

simran.



-----Original Message-----
From: Ken Y. Clark [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, 7 November 2001 12:24 AM
To: James Wilson
Cc: [EMAIL PROTECTED]
Subject: Re: CGI.pm - Unnamed parameter


On Fri, 2 Nov 2001, James Wilson wrote:

> Date: Fri, 2 Nov 2001 01:42:13 +0000 (GMT)
> From: James Wilson <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: CGI.pm - Unnamed parameter
>
> Hi,
>
> Hopefully a quick and easy question...
>
> I'm accessing as follows:
>
> /cgi-bin/script.pl?data
>
> And want to know how to get 'data' from somewhere using CGI.pm
>
> Am familiar with using $cgi->param{'it'} to read .../script.pl?it=data
> and also using $cgi->path_info() to read .../script.pl/data
> but I don't know how to get at it using the format at the top. I've
> noticed from experiment that given /script.pl?data, I seem to be
> able to get it using $cgi->param{'keywords'}, but if I am using
> .../script.pl?param=value&data then I can access 'value' from
> $cgi->param{'param'}, but can no longer get 'data' from
> $cgi->param{'keywords'}
>
> I'm therefore obviously concerned about just asssuming that
> $cgi->param{'keywords'} will return 'data' given an access of
> .../script.pl?data as I can find no reference in CGI.pm docs
> about this being a standard behaviour.
>
> Does anyone know a fail-safe way of retrieving 'data'
> using a CGI.pm call given an access as above ???
>
> Thanks,
>
> James

James,

Do you have to use CGI.pm?  Why not use the Apache::Request module?
It's much quicker and powerful, IMO.  $apr->path_info() should work
just fine for you, but it's only going to give you the "data" part of
"/script.pl?data."

Also, if you're going to stick to using CGI.pm, why are you saying
"$cgi->param{'foo'}" and not making the method call,
"$cgi->param('foo')"?

ky

Reply via email to