... # invoke our template my $t = HTML::Template->new(filename => 'foo.html', filter => \&filter); # prepare an array of hashes for a loop my @foobar; push @foobar, { barfoo => $_ } for (1..4); # one way to set an if statements control param $t->param( qux => 1 ); # fill in our params $t->param( foo => 'Camels of the World', bar => [ { baz => 'Bactarian', baaz => 'Dromedary', foobar => \@foobar } ] ); # output it print $t->output;