Stinger has asked for the wisdom of the Perl Monks concerning the following question:

Sorry for that first mess. I didn't know this was an HTML window.

I patched this example together as a very simple program that is supposed to take the output from a form and produce another form with the parsed apart form entries. But it only returns a blank form. Am I missing something?

NOTE: I am using a GTE sponsered web site and they told me I needed the first 3 lines exactly as shown. At least when I followed this the "internal server" error went away and I at least saw a blank form returned.

I am an experienced C++ and VB programmer, but Perl is brand new to me. And comments are welcomed. Here it is, with the (code) tags this time.
#!/usr/local/bin/perl use CGI qw(:cgi-lib :standard); print header(); # geturl.pl # # A little Perl script to read, decode and print the names # and values passed to it from an HTML Form thru CGI. # Get the HTML header, ender, define the page title. require "/cgi-local"; # full path # print "Content-type: text/html\n\n"; $Title = "Get Information From a URL"; # Get the query string # $QueryString = $ENV{'QUERY_STRING'}; # Use split to make an array of name-value pairs broken at # the ampersand char. @NameValuePairs = split (/&/, $QueryString); # Put up an HTML header, page title, and a rule. &HTML_Header ($Title); print "<BODY>\n"; print "<H1>$Title</H1>\n"; print "<HR>\n"; # Split each of the name-value pairs and print them on the page. foreach $NameValue (@NameValuePairs) { ($Name, $Value) = split (/=/, $NameValue); print "Name = $Name, Value = $Value<BR>\n"; } &HTML_Ender;

Replies are listed 'Best First'.
Re: Beginning Perl & Forms - 2
by hotyopa (Scribe) on Jan 19, 2001 at 03:27 UTC
    Make sure you have a look at the CGI man page, the documentation is pretty thorough and easy to follow.

    Also have a look at Carp- it replaces those horrible HTTP 500 errors with something a little more useful.

    The following script should do what you want though (and hopefully point you in the right direction):

    #!/usr/bin/perl -wT use CGI; use CGI::Carp qw(fatalsToBrowser); #makes any error messages appear in + the browser $query = new CGI; #instantiates new CGI object @params = $query->param; #fetches names of all parameters passed to +the script print $query->header,$query->start_html('Show Params'); #prints h +ttp header, html tags up to <body> #loop through the list of parameters and print each out on #a separate line. foreach $parameter(@params) { print $parameter, ": ", $query->param($parameter), $query->br; } print $query->end_html;

    *~-}hotyopa{-~*

Re: Beginning Perl & Forms - 2
by wardk (Deacon) on Jan 19, 2001 at 03:08 UTC

    the second line indicates that you have access to CGI.pm. So you have alot of power to manage html forms at your fingertips.

    You should avoid using the cgi-lib functions (just leave the :standard) that is included as backwards-compatibility with the older cgi-lib.

    Do some searching for CGI.pm, here is the manual CGI.pm

    a simple seach here for CGI.pm should give you more than enough information to get rolling.

    good luck!