#!/usr/bin/perl -w use strict; use File::Find; my (@sigs, $rndm_file); find(sub { push(@sigs, $_) if -f and /(\.html?)$/i }, '/path/to/sigs/directory'); $rndm_file=$sigs[rand($#sigs+1)]; open SIG, "<$rndm_file" or die $!; print "Content-Type: text/html\n\n"; printf '%s', defined(SIG) ? : 'Nothing.'; close SIG or die $!;