$i = 0; while($i <= $directories) { push @loop_data, { SMILIE => $directories[$i++], }, ; } $subtemplate->param(LOOP => \@loop_data);