#!/usr/bin/perl use strict; $|++; use Template; my $tt = Template->new; my %data = ( bar_every => 2, colors => [qw( red orange yellow green blue indigo violet silver gold )], ); $tt->process(\*DATA, \%data); exit; # To make the template below work (exept for inserting the bars), # Just delete or comment the 'IF' and the two following lines __DATA__ [% cnt = 0 %] We're going to print a bar every [% bar_every %] items. [% FOREACH color = colors -%] [% cnt = cnt + 1 -%] [%cnt %] The color is [% color %]. [% IF cnt % bar_every == 0 -%] ---- [% END -%] [% END -%]