#!/usr/bin/perl # my $dir = shift @ARGV; unless ($dir || -d $dir) { die "Usage:\n makemoodindex.pl \n"; } print "Making mood index for $dir\n"; @colors = qw(ffffff 333333 663300 ff9900 ffff33 00ff00 006600 009999 0066cc 9900cc ff3399 ff0000 cccccc 000000 cccc99 ffcc99 ffffcc ccffcc 339933 99ffff 99ccff cc99ff ff99cc ffcccc); opendir (DIR, $dir); @files = readdir DIR; closedir DIR; if (-e "$dir/index.html") { open (HTML, "$dir/index.html"); my $line = ; chomp $line; unless ($line eq "") { die "Won't overwrite index.html in this directory!\n"; } } open (HTML, ">$dir/index.html"); print HTML "\n"; print HTML "\n"; print HTML <<"CHOOSER_HEADER";
•• click for background color ••
CHOOSER_HEADER my $count = 0; foreach my $col (@colors) { if (++$count == 13) { print HTML "\n\n"; } print HTML "\n"; } print HTML "
\n\n"; foreach my $file (sort @files) { next unless (-d "$dir/$file" && $file ne "."); print HTML "$file/
\n"; } print HTML "\n"; foreach my $file (sort @files) { next unless ($file =~ /\.gif$/); print HTML ""; print HTML ""; print HTML "\n"; } print HTML "
$file
\n";