I'd suggest using glob() to grab the file listing, randomizing that using the permutation code that floats around here alot, and then doing the foreach on that...
print "Content-type: text/htlp\n\n";
$n=1;
@files = glob("random/*.html);
fisher_yates_shuffle(@files); # see the Perl Cookbook for this functio
+n
foreach $file (@files) {
...
}