Ovid's tutorial is pretty good. The thing to remember with CGI is that the apache webserver(usually) is acting as an interface between your application and the remote user's browser. This replaces the STDIN-STDOUT which you are used to.

So you need to set up forms which the remote user can fill in and send to the web server, which will relay it to your app. Now you can manually make your forms, or you can generate them dynamically with CGI.pm or with here-documents. I prefer to use here-docs myself. Here is a little cgi program which will display your form variables for testing.

#!/usr/bin/perl use warnings; use strict; use CGI; my $cgi=new CGI; my %in = $cgi->Vars(); print "Content-type: text/html\n\n"; foreach my $key (keys %in){ print "$key -> $in{$key}<br>"; }

Now you takes those form variables, process them with your application, and send them back out to apache, which relays them to the user's browser. You can display them anyways you like, from a simple text output, to a fancy html table. The output format can be generated manually( with here-docs) or you can use CGI.pm's features to generate output. The important thing is to observe the protocols for generating the right type of "header" so that apache will send it, and it will look like you want. The more advanced users will recommend using a templating system for producing your output, like HTML::Template.

Generally, apache will accept your output if you start your script with the standard header:

print "Content-type: text/html\n\n";
then
print 'here is all your output<br>'; print $output;
Remember that the browser expects <br> instead of \n.

I'm not really a human, but I play one on earth. flash japh

In reply to Re: Getting CGI parameters by zentara
in thread Getting CGI parameters. by stalkeyefly

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.