Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CGI.pm post types

1 view
Skip to first unread message

Bruce Ferrell

unread,
Dec 30, 2009, 5:28:51 PM12/30/09
to begi...@perl.org
I see on the CGI web page that this:
===================================
use CGI;

$q = new CGI;

$query = $q->param( 'POSTDATA' );
===================================


will return the contents of this URI:

http://server/cgi.cgi?POSTDATA=posteddata

How do I code so that I don't have to use POSTDATA?

I know it's a silly question and probably obvious, but not to me

Thanks

Shlomi Fish

unread,
Dec 30, 2009, 5:37:29 PM12/30/09
to begi...@perl.org, Bruce Ferrell
On Thursday 31 Dec 2009 00:28:51 Bruce Ferrell wrote:
> I see on the CGI web page that this:
> ===================================
> use CGI;
>
> $q = new CGI;
>
> $query = $q->param( 'POSTDATA' );
> ===================================
>
>
> will return the contents of this URI:
>
> http://server/cgi.cgi?POSTDATA=posteddata
>

In this case "$query" will return "posteddata", the value of the HTTP
parameter of POSTDATA (a "GET" one in this case.).

> How do I code so that I don't have to use POSTDATA?

What do you want to do exactly?

Regards,

Shlomi Fish

>
> I know it's a silly question and probably obvious, but not to me
>
> Thanks
>

--
-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/
Interview with Ben Collins-Sussman - http://shlom.in/sussman

Bzr is slower than Subversion in combination with Sourceforge.
( By: http://dazjorz.com/ )

Bruce Ferrell

unread,
Dec 30, 2009, 5:44:31 PM12/30/09
to Shlomi Fish, begi...@perl.org

Shlomi Fish wrote:
> On Thursday 31 Dec 2009 00:28:51 Bruce Ferrell wrote:
>> I see on the CGI web page that this:
>> ===================================
>> use CGI;
>>
>> $q = new CGI;
>>
>> $query = $q->param( 'POSTDATA' );
>> ===================================
>>
>>
>> will return the contents of this URI:
>>
>> http://server/cgi.cgi?POSTDATA=posteddata
>>
>
> In this case "$query" will return "posteddata", the value of the HTTP
> parameter of POSTDATA (a "GET" one in this case.).
>
>> How do I code so that I don't have to use POSTDATA?
>
> What do you want to do exactly?
>
> Regards,
>
> Shlomi Fish
>
>> I know it's a silly question and probably obvious, but not to me
>>
>> Thanks
>>
>

Well, I thought something I was looking at implied I didn't have to use
name/value pairs. I got out my handy dandy sniffer and it appears I was
utterly incorrect... Unless you tell me otherwise :)

Shlomi Fish

unread,
Dec 31, 2009, 12:19:51 AM12/31/09
to begi...@perl.org, Bruce Ferrell

Well, you can always use PATH_INFO:

http://myhost.tld/cgi-bin/my.cgi/more/path/here/

And retrieve it using $cgi->path_info().

Is this what you are looking for?

Regards,

Shlomi Fish

--
-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/

Parody on "The Fountainhead" - http://shlom.in/towtf

Jeremiah Foster

unread,
Dec 30, 2009, 9:14:02 PM12/30/09
to Bruce Ferrell, begi...@perl.org

On Dec 30, 2009, at 23:28, Bruce Ferrell wrote:

> I see on the CGI web page that this:
> ===================================
> use CGI;
>
> $q = new CGI;
>
> $query = $q->param( 'POSTDATA' );
> ===================================
>
>
> will return the contents of this URI:
>
> http://server/cgi.cgi?POSTDATA=posteddata
>
> How do I code so that I don't have to use POSTDATA?

It was you who defined the variable name, i.e. POSTDATA. You can change the name to something else.

Or are you trying to get rid of the key value pairs entirely? That unfortunately won't work since HTTP is a 'stateless' protocol and if you want the remote machine to calculate something with your input you'll have to provide input and key value pairs is the way its done.

Jeremiah

0 new messages