Skip to content

Instantly share code, notes, and snippets.

@unixmonkey
Created December 10, 2012 15:14
Show Gist options
  • Select an option

  • Save unixmonkey/4251165 to your computer and use it in GitHub Desktop.

Select an option

Save unixmonkey/4251165 to your computer and use it in GitHub Desktop.
Perl Template Toolkit example using __DATA__ as template
#!/usr/bin/env perl
use strict;
use warnings;
use Template;
my @coordinates = [
11, 22, 39, 393, 102, 102
];
my $vars = {
title => 'Hello, World!',
coordinates => @coordinates,
};
my $template = Template->new();
$template->process(\*DATA, $vars) || die $template->error(), "\n";
__DATA__
Content-type: text/html
<!DOCTYPE html>
<html>
<head>
<title>[% title %]</title>
</head>
<body>
[% FOREACH coordinate IN coordinates %]
<li>[% coordinate %]</li>
[% END %]
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment