http://www.perlmonks.org?node_id=478196


in reply to Starting with Perl

I highly recommend HTML::Template for small projects. It's still a templating system, and gives you the advantages of that, but it's also very light and easy to understand.

Templates are nice because you can spend less time debugging HTML inside Perl. With a template, you can design your layout using HTML-editing tools, then replace variable chunks with template variables. If you're familiar with PHP, HTML::Template will not be difficult. Observe a small chunk of an HTML::Template template:

<p>Hi, you are logged in as <!-- TMPL_VAR NAME=username -->, and you have <!-- TMPL_VAR NAME=new_message_count --> new messages.</p +>

A snippet of Perl to populate the variables in the file (which we'll pretend is named template.html):

use HTML::Template; my $template = new HTML::Template (filename=>'template.html'); $template->param( 'username' => $username, 'new_message_count' => get_new_count($username), ); $|=1; ##unbuffered output is a good idea with CGI print $template->output; ## sends to browser;

As for an equivalent to PHP's include(), read the docs on require. One use of it is like this:

require 'myfile.pl';

The above would load myfile.pl and process its contents.

<-radiant.matrix->
Larry Wall is Yoda: there is no try{} (ok, except in Perl6; way to ruin a joke, Larry! ;P)
The Code that can be seen is not the true Code
"In any sufficiently large group of people, most are idiots" - Kaa's Law