#!/usr/bin/perl -wT use strict; use CGI; use Image::Size; my $q = new CGI; my $imageDir = "./"; my @images; opendir DIR, "$imageDir" or die "Can't open $imageDir $!"; @images = grep { /\.(?:png|gif|jpg)$/i } readdir DIR; closedir DIR; print $q->header("text/html"), $q->start_html("Images in $imageDir"), $q->p("Here are all the images in $imageDir"); foreach my $image (@images) { my ($width, $height) = imgsize("$image"); print $q->p( $q->a({-href=>$image}, $q->img({-src=>$image, -width=>$width, -height=>$height}) ) ); } print $q->end_html;