Page 1 of 1

Forms using Perl CGI & Apache 2.2

PostPosted: 11. February 2012 06:18
by todddyer
Howdy all,

I am running ActivePerl 5.14.2 & Apache 2.2.

I have been trying to get a simple form working using Perl/CGI, and I cannot get the buttons to show up in my browser.

I am running my cgi scripts from a browser, and the titles will show up okay, but no input buttons.

Here are a couple of examples:

This script:

#!C:\perl\bin\perl.exe -w
use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use strict;

print header;
print start_html("Thank You");
print h2("Thank You");

my %form;
foreach my $p (param()) {
$form{$p} = param($p);
print "$p = $form{$p}<br>\n";
}
print end_html;


Yields this output: (just the title and not the form is displayed)

Thank You



Here is another example:

This script:

#!C:\perl\bin\perl.exe -wT
use CGI;
$q = new CGI;
$name = $q->param('name');
$address = $q->param('address');
print "Content-type:text/html\n\n";
print <<END_OF_MESSAGE;
<html>
<title>Thank You Page</title>
<h1>Thank you for filling out my form!</h1>
Thank you, $name, for filling out my form!
I will mail information to $address right away.
</html>
END_OF_MESSAGE

Yields this result:

Thank you for filling out my form!
Thank you, , for filling out my form! I will mail information to right away.

No input asked for.

I am such a noob at this. Can anyone point me in the right direction? I am not even sure what to check next to begin troubleshooting.

Thanks!
Todd

Re: Forms using Perl CGI & Apache 2.2

PostPosted: 14. February 2012 14:03
by JonB
My honest suggestion is that you get a book on Perl, its a tough conceptual language. (that's what I did/do, I have dozens of books on Perl, PHP MySQL and so forth)

Here's a good one:

Learning Perl
http://shop.oreilly.com/product/0636920018452.do

You don't have to have the latest edition, unless you 'really plan' to be a Perl Programmer or if you want to learn the 'latest techniques' and language features. You can buy older editions for a few bucks on abe.com or eBay.

There are code examples to follow, and O'Reilly Books publishes the most titles on Perl - they are kinda the gold standard. I have 6 OR books on Perl currently.

Good Luck
8)