Nieuwjaar in de Purmer

#! /usr/bin/perl use warnings FATAL => 'all'; use strict; use Data::Dumper; use File::Spec; use CGI qw( :standard ); use CGI::Carp; my $directory = param( 'keywords' ) || '.'; my $width = 6; my $dir = File::Spec->catdir( $ENV{DOCUMENT_ROOT}, "familie", $directory ); chdir $dir or die "$dir: $!"; local *IMGDIR; opendir IMGDIR, '.' or die "Can't readdir: $!"; my @jpg = grep -f && /\.jpg$/i => readdir IMGDIR; closedir IMGDIR; my( %small, %big ); foreach my $img ( @jpg ) { $img =~ /(\w+?)_s\.jpg$/i and do { $small{ $1 } = $img; next; }; $img =~ /(\w+)\.jpg$/i and do { $big{ $1 } = $img; next; }; } my @sorted = sort keys %big; my $col = 0; my @rows; foreach my $keyname ( sort keys %big ) { $rows[ int $col / $width ][ $col % $width ] = a( { href => "show_img.cgi?$keyname" }, img({ src => $small{ $keyname }, style => 'border:0;', alt => '[klik voor een grotere foto]' }) ); $col++; } push @{ $rows[-1] }, " " while @{ $rows[-1] } < $width; print header(), table( { border => 2 }, map Tr( map td( $_ ) => @$_ ) => @rows );