opendir DIR, $dir; while ($file = readdir DIR) { if ($file =~ /\.jpg$/) { push @images, { 'image' => $file }; } } closedir DIR; #### use HTML::Template; $t = HTML::Template->new(filename => 'dropdown.tmpl'); $t->param(IMAGES => \@images); print "Content-Type: text/html\n\n", $t->output; ####