#!/usr/bin/perl use warnings; use strict; use File::Find; use HTML::Template; my $template = HTML::Template->new(filename => 'gallery.tpl'); my @thumbnails; my $count = 1; my %options = (wanted=>\&pics , no_chdir=>1); find(\%options, 'thumbs/'); $template->param(THUMBNAIL => [ @thumbnails ] ); print "Content-Type: text/html\n\n", $template->output; sub pics { return unless /\.((?:jpg)|(?:gif)|(?:png)$)/i; my $thumbfile = "$_"; my $imagefile = "$_"; $imagefile =~ s/thumbs/images/; push @thumbnails,{image=>$imagefile, thumb=>$thumbfile, newrow=>$count%5}; ##This is the imporant bit $count++; } #### Image Gallery