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

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello y'all. I'm trying to do a nested loop in HTML::Template. My webapp grabs a list of directories and a bunch of files from those directories. I wish to display a table which includes the directory name followed by rows of 5 filenames (each one in a column). My current template is as follows:
<html> <head> <title><TMPL_VAR NAME="title"></title> </head> <body> <center> <table> <TMPL_LOOP NAME="dir_loop"> <tr> <th colspan="5" bgcolor="#E0E0E0"><font size="+3"><TMPL_VA +R NAME="dir"></font></th> </tr> <TMPL_LOOP NAME="outter_file_loop"> <tr> <TMPL_LOOP NAME="inner_file_loop"> <td colspan="5"><TMPL_VAR NAME="filename"></td> </TMPL_LOOP> </tr> </TMPL_LOOP> </TMPL_LOOP> </table> </center> </body> </html>
It starts with the dir_loop -- for each dir. The outter_file_loop is for each row, and the inner_file_loop is for each item in the row. My questions are as follows: Does the template look like it would work? If so, how would I construct the array & hashes to make it work? Is there a better way to do it (<- this should probably be asked first)? Thanks in advance. -Brian