#!/usr/bin/perl -w print "Content-type: text/html\n\n"; $dir = "/home/usr/public/images/"; $view = "view.html"; $number_to_show = 15; $title = "Your Title Could Go Here"; srand( time() ^ ($$ + ($$ << 15)) ); opendir DIR, "$dir"; my @arr = grep -f, grep /\.jpg$/i, map "$dir/$_", readdir DIR; $n = @arr; foreach (reverse 0..$n) { my $pic = splice(@arr, rand $n, 1); push @arr, $pic; $#arr = $number_to_show; } &print_it(); sub print_it { open (PAGE, "$dir$view") || die ("I am unable to open the template $view"); while () { s/%%title%%/$title/g; s/%%images%%/@arr/g; print $_; } close (PAGE); }