I cannot read from STDIN in cgi-styled script
stan2004
created: 2004-07-02 09:56:54
Hi everyone!
I'm newbie in cgi-perl programming and I have such problem:

when cgi script read data, posted from html form with "post" post method, the read sub return zero of readed bytes, but $ENV{'CONTENT_LENGTH'} hold (for example) 7 bytes.

Any idea? Where I'm wrong ?

Here is my html from and cgi script:

===========================
some_file.html
---------------------------






============================== ================================ script.pl: -------------------------------- #!/usr/bin/perl use CGI qw/:standard/; print header; $length = $ENV{'CONTENT_LENGTH'}; $count = read (STDIN, $buffer, $length); print "readed actually: $count, length: $length"; ================================
output in browser:
readed actually: 0, length: 7

Yes, I may solve this problem when getting form input touch CGI.pm, but the code above is correct, isn't it?

Edit by [tye], remove PRE tags, other formatting clean-up

•Re: I cannot read from STDIN in cgi-styled script
created: 2004-07-02 10:00:19
Once you've issued "use CGI", then the CGI module is managing your GET/POST data for you, including slurping up STDIN as needed. Look at the param method/routine in the CGI docs to get at your data.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

perlmonks.org content © perlmonks.org and merlyn, stan2004

prlmnks.org © 2006 edmund von der burg (eccles & toad)

v 0.03