#!/usr/bin/env perl use strict; use warnings; use HTML::Template; my @sources = ( "Hello \n", "Goodbye \n", ); my @templates; # Create and populate 2 templates with one loop for my $source (@sources) { my $tmpl = HTML::Template->new (scalarref => \$source); $tmpl->param (FOO => 'StrangeDucks'); push @templates, $tmpl; } # Output from the two teamplates for my $t (@templates) { print $t->output }