in reply to Problem with read( STDIN, $query_string, $ENV{'CONTENT_LENGTH'} );
Don't do this yourself, even with help from some book, unless you've first used CGI or another module from the Perl core or from CPAN and found it doesn't do what you need.
The modules made to deal with this have been thoroughly specified, written, debugged, and maintained by several programmers over years of use by thousands of other programmers. They do it the right way. Trust them more than some book (even an O'Reilly book) last updated ten years ago. CGI.pm itself is a core module since Perl 5.004 and is over twelve years old. It was most recently updated on CPAN less than a year ago.
Hint: one thing that's wrong here is that POST is a different form method than GET, just as the name "method" implies. The data doesn't move from client to server the same way. In GET, it's part of the query string. In POST, the posted data is not part of the query string (which is why you can't find it there).
You have to get POST data another way. I'm not going into the specifics of that, because I really want you to use a well-vetted module. If you do, you won't have to even worry about how it's done. Besides, it's possible to have a form sent with POST and have data sent in the query string at the very same time as well. If I told you how to get POST data, your solution would probably not get both the POST data and the query string data after it branched between POST and GET. That's a common error even for programmers that have checked into how to do both: their code still won't handle POST data and a query string. CGI.pm will, and you don't even need to know which data came which way in the vast majority of cases. The data is retrieved through the API the very same way regardless.
|
|---|