in reply to How to use Perl in web pages?
The simplest of all ways is to use the CGI module and just print out your HTML:
#!/usr/bin/perl -w use strict; use CGI; my $q = CGI->new; my $name = $q->param('name'); print $q->header(); # just ignore the man behind the curtain print '<html><title>First page</title><body>'; if (defined $name) { print "<h1>Hello $name</h1>"; } else { print "<h1>Please enter your name</h1><form action=''><input name= +"name" type="text"></form>"; }; print '</html>';
In short time though, you will want to move to one of the templating systems. If you feel at home with the code-intermingled-with-HTML way of PHP, then Mason might be your thing. If you want to get away as far as possible from that, take a look at Petal, HTML::Seamstress and HTML::Template. The Template Toolkit has its own powerful programming language built in, so you can get more creative with these templates, but, again, beware of the danger of mixing code and HTML too much.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to use Perl in web pages?
by liverpole (Monsignor) on Jun 07, 2009 at 02:34 UTC | |
|
Re^2: How to use Perl in web pages?
by kitsune (Acolyte) on Jun 06, 2009 at 22:24 UTC | |
by graff (Chancellor) on Jun 07, 2009 at 01:58 UTC | |
by hangon (Deacon) on Jun 07, 2009 at 00:24 UTC |