#!/usr/bin/perl -s $indexfile = "index.html" unless $indexfile; foreach $path (@ARGV) { next unless (-d $path); &do_dir($path); } sub do_dir { local($dir) = @_; $dir .= "/" unless $dir =~ m|/$|; if(! -e $dir."/$indexfile") { print "$dir is insecure!\n"; if($secure) { open(F,">$dir/$indexfile"); print F << 'EOF'; Redirect This is not a browsable directory. You must be looking for the home page, click here. EOF close(F); } } opendir(D, $dir); local(@fs) = (); while($f = readdir(D)) { next if $f =~ m|^\.+$| ; @fs = (@fs, $f); } closedir(D); @fs = sort @fs; while($f = shift @fs) { if( -d $dir . $f . "/" ) { &do_dir($dir . $f . "/"); } } }