Forum Moderators: open
i.e.
print "Content-Type: text/html\n\n";
print "<html><head><title>Thank You</title></head>\n";
print "<body>Thank You\n";
print "The information has been sent and here is what you submitted:<hr>\n";
print "</body></html>\n";
At least, that's what I do.
[perl]
print "Content-Type: text/html\n\n";
$var1 = 'stuff';
$var2 = 'otherstuff';
$var3 = 'yetmorestuff';
open(FILE, "template.html") or die "could not open template.html $!";
while(<FILE>){
s/_var1_/$var1/ig;
s/_var2_/$var2/ig;
s/_var3_/$var3/ig;
print;
}
close(FILE);
exit;
[/perl]
the _var1_ _var2_ and _var3_ are pointers in the html file template.html that you are searching and replacing with the contents of the three variables, $var1, $var2, and $var3.
This way you can add a lot of stuff really quickly, and leave your code such that if you change the design of your site, you don't have to modify your code.
I've saved myself a lot of time doing it this way, instead of simply printing the html from within perl.
Of course, you can also use the CGI.pm module for that, but I've always thought of that as overkill (how much perl do you need for CGI anyway?).
Hope that helps.
The html form should point to that perl script eg:
<form action = "./script.cgi">