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
In reply to I cannot read from STDIN in cgi-styled script by stan2004
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |