I am trying to provide a simulation on Web request, GET and POST, during my shell development, coz I don't want to implement a batch form query combination and see the results via my browser. This is very inefficient if I use my browser to fill in the blanks, change something and submit again time to time.

My simulation module is simply to set $ENV{REQUEST_METHOD} = "GET" and then $ENV{QUERY_STRING} = "Var1=Val1&Var2=Val2" (when I run the code in shell) Now the GET request is done, but the POST request won't work as it read (STDIN, my $buf, 4096) and I can't find anyway to feed the STDIN

My recent shortcoming approach it to alter a POST request to GET and URI encode the data string, it works on some cases, however it won't pass through when somecgi.pl performs :

if ( $ENV{REQUEST_METHOD} eq "GET" ) { print_the_form(); } elsif ( $ENV{REQUEST_METHOD} eq "POST" ) { handle_the_form(); } else { print "GET and POST request only" }
Any clues for this ? Thanks a lot!

In reply to Is it possible to write to STDIN ? by exilepanda

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.