I guess the author assumes having this running within a webserver...

Yes. A web server passes what are called "environment variables" to perl scripts using a gateway called 'cgi'. The perl script can then access a global hash that is populated with the form data. The server has to be setup so that it recognizes when it is supposed to pass information to a perl script.

You can transfer data directly from one program to another program using sockets, which is not exactly an easy subject to learn, but a js script cannot open up a socket. So it is more than likely that you are very confused about what you want to do--or you are trying to do something that is specifically prohibited by js scripts for security reasons.

The article you read is trying to show how a perl script can get form information from a web server without using the assistance of any perl modules, like CGI.pm. In contrast, the CGI.pm module saves you from having to parse the information by hand. The CGI.pm module does the parsing for you and puts the form information in a global hash, where the keys are the names of the form input elements, and the values are what the user entered in those input elements. You can parse the data yourself or use the CGI module to parse the data for you--but in both cases a web server has to process the form data first, then pass it to the perl script.


In reply to Re: Getting HTTP POST without webserver?? by 7stud
in thread Getting HTTP POST without webserver?? by bgi

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.