The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

EXAMPLE

    #!/path/to/perl -w
    use strict;
    use Template;
  
    # create a template processor
    my $tproc = Template->new({ 
        INCLUDE_PATH => '/user/abw/templates', # template search path
    });
  
    # define variables for use in templates
    my $vars  = {
        'animal' => 'cat',
        'place'  => 'mat',
        'list'   => [ 'foo', 'bar', 'baz' ],
        'user'   => { 
            'name'  => 'Me, Myself, I', 
            'email' => 'me@here.com'  
        },
    };
  
    # process a template file, output defaults to STDOUT
    $tproc->process('myfile', $vars)
        || die $tproc->error(), "\n";

myfile:

    [% INCLUDE header
       title = 'Hello World!'
    %]

    The [% animal %] sat on the [% place %]

    <a href="mailto:[% user.email %]">[% user.name %]</a>

    <ul>
    [% FOREACH item = list %]
       <li>[% item %]
    [% END %]
    </ul>

Output:

    <!-- ...output from processing 'header' template... -->

    The cat sat on the mat

    <a href="mailto:me@here.com">Me, Myself, I</a>

    <ul>
       <li>foo
       <li>bar
       <li>baz
    </ul>