[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Getting data into a CGI script



At 10:55 am +0100 8/9/98, Sean Carte wrote:
>>From reading the archives I've concluded that the read function is
>usually used for getting posted data into a cgi script, like this:
>
>read(STDIN, $Var, $ENV{"CONTENT_LENGTH"})

Nope... CGI.pm is "usually" used... it will save you a *lot* of pain...
promise :-)

>I have a problem, however, in that the program sending data to the CGI
>(Authorware Shockwave) does not provide data for the CONTENT_LENGTH
>variable. I need some other way of reading in the data from <STDIN>. I've
>tried:
>
> while (<STDIN>) {
>		$string = $string . <STDIN>;
>}
>
>but that doesn't work; it seems to get itself into a loop and eventually
>time out. Is there another way that I can get the cgi to step through
><STDIN> until it's empty?

Something more like this...

	my $output = '';
	my ($n, $buff);
	while ($n = read(STDIN, $buff, 1024)) {
		$output .= $buff;
	};

will do the job (with a bit more error checking...).

However, if you use CGI.pm then you won't have to worry about GET vs POST,
differing ENCTYPEs, un-escaping/escaping keys/values, etc. etc....

Hope this helps,

Adrian

>
>My brain hurts!
>SeanC
>                     Mediatek Training Institute
>   1st Floor Media Park, 129 Moore Road, Berea, Durban, South Africa
>   phone: +27 (0)31 305 4200              SeanC@mediatek.co.za
>   fax: +27 (0)31 305 4236                Mediatek@global.co.za
>
>
>***** Want to unsubscribe from this list?
>***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch


----
Adrian Howard. adrianh@victoriareal.co.uk. Head Techie. Victoria Real Ltd
URL: http://www.victoriareal.co.uk/ v. +44 1273 702007 f. +44 1273 706007



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch