I have been stuck on a problem for 2 days now, and how looked on the iternet and this site for the answer but unable to find it.

The Problem:

I am trying to process information from a form, that is processed by calling another Perl script ("testLoginData.pl"). I 'POST' the information to the script and then call a sub from a module ('parse_data_both.pm'). I have tested this fairly thoughly and I have used the 'parse_form_data' script from "CGI Programming on the World Wide Web" Chap 4.3. I have used the GET method, and that works fine, but with the post method the line: read( STDIN, $query_string, $ENV{'CONTENT_LENGTH'} ); doesn't fill the $query_string with anything.

The code:

HTML Form line

<form method="post" action="../bin/testLoginData.pl" enctype="multipar +t/form-data">

testLoginData.pl code:

#!c:\Perl\bin\perl use warnings; use parse_data_both; use GUI; use CGI; use constant USERNAME_TEST_PASS => 42; my $q = CGI->new; &DataHandler::parse_form_data (*simple_form);

The parse_data_both.pm module code:

#!c:\Perl\bin\perl use warnings; package DataHandler; $webmaster = 'admin@zixsys.com'; use constant USERNAME_TEST_PASS => 42; sub parse_form_data { print "Content-type: text/plain", "\n\n"; local (*FORM_DATA) = @_; local ( $request_method, $query_string, @key_value_pairs, $key_value, $key, $value ); print "Run Test", "\n"; $request_method = $ENV{'REQUEST_METHOD'}; print "The data sent to FORM_DATA is:", @_, "\n"; if ( $request_method eq "GET" ) { $query_string = $ENV{'QUERY_STRING'}; print "GET query_string is:", $query_string, "\n"; } elsif ( $request_method eq "POST" ) { read( STDIN, $query_string, $ENV{'CONTENT_LENGTH'} ); print "POST query_string is: ", $query_string, " and the length is: $ENV{'CONTENT_LENGTH'}\n"; }
Thank you in advance for any help you can offer

In reply to Problem with read( STDIN, $query_string, $ENV{'CONTENT_LENGTH'} ); by KyussRyn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.