#!/usr/bin/perl -- use strict; use warnings; use HTML::Template; my $tmpl = q{ Name: Nicknames: -: }; my $data = { LOOP => [ { name => 'Bobby', nicknames => [{name => 'the big bad wolf'}, {name => 'He-Man'}], }, ], }; for(1..2){ my $template = HTML::Template->new( scalarref => \$tmpl, ); $template->param( %$data ); $template->output(print_to => *STDOUT); } __END__ Name: Bobby Nicknames: -: the big bad wolf -: He-Man Name: Bobby Nicknames: -: the big bad wolf -: He-Man