[% LAST %] is not the same as loop.last().
The data you've shown is a little too messy for me (to try to fix it up to actually match its usage in the given template...), but the general idea would be something like this:
my $data = { employee => [ { name => 'Foo' }, { name => 'Bar' }, { name => 'Baz' }, ] }; my $template = Template->new(); $template->process(\*DATA, $data) || die "Template process failed: ", $template->error(), "\n"; __DATA__ [% FOREACH person IN employee %] [%- IF loop.index() %][% loop.size()>2 && loop.last() ? ' or':',' +%] [% END %] [%- person.name %] [%- END %].
Output:
Foo, Bar or Baz.
In reply to Re^3: help me with template module to print like this
by Eliya
in thread help me with template module to print like this
by veerubiji
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |