http://www.perlmonks.org?node_id=1077449


in reply to Template Toolkit - problem getting data out array - AoHoA

I think your structure is fine. You just have to think more “perlishly” for your iteration. This should get you on the path to what you want–

use strictures; use Template; my $stuff = [ { 'filenameLarge' => [ 'fIyvYwJWmstR.jpg', 'koeSHYEaekfv.jpg', 'CtDKXyiRXhWz.jpg' ], 'title' => 'February event (Feb 2013)', 'bookid' => 8 } ]; my $tt = Template->new; $tt->process(\*DATA, { fotos => $stuff }) || die $tt->error(), "\n"; __DATA__ [%-FOR e IN fotos %] [%-e.title %] [%-FOR i IN e.filenameLarge %] <img src="/photo/[% e.bookid %]/tn/[% i %]" /> [%-END %] [%-END %]

Yields–

February event (Feb 2013) <img src="/photo/8/tn/fIyvYwJWmstR.jpg" /> <img src="/photo/8/tn/koeSHYEaekfv.jpg" /> <img src="/photo/8/tn/CtDKXyiRXhWz.jpg" />