stan2004 has asked for the wisdom of the Perl Monks concerning the following question:
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:
output in browser:=========================== some_file.html --------------------------- <html> <head> </head> <body> <form action="/cgi-bin/script.pl" method="POST"> <input type="text" name="query"> <br> <input type="submit"> </form> </body> </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"; ================================
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
•Re: I cannot read from STDIN in cgi-styled script
by merlyn (Sage) on Jul 02, 2004 at 14:00 UTC |