#!/usr/bin/perl -w
### script began to index image files in a directory
## PBM
use strict;
use Cwd;

 open(OUT, ">index.html") or die "Can't open index file: $!\n";
&printhead();
&processfiles();
&printtail();

  sub printhead{
                my $curr = cwd();
                print OUT "<HTML>\n<HEAD>\n";
                print OUT "<TiTLE> Listing of files in the directory </TITLE>\n";
                print OUT "</HEAD>\n<BODY>\n";
                print OUT "<H1>Directory Index</H1>\n";
                print OUT "<P>";
                }
  sub processfiles {
                opendir(CURRDIR, '.') or die "Cant open direcotry ($!), exiting.\n";
                my $file = "";
                while (defined($file = readdir(CURRDIR))) {
                                                           if (-f $file ) {
##begin my hodgepodge to add descriptions 
                     print "please enter a description of the file '$file'\n";
                     my $desc =<STDIN>;
                     chomp $desc;

                                    
				print OUT "<A HREF=\"$file\">$file --> $desc</A><BR>\n";
      														}
                                                          }
##end my hodgepodge
		closedir(CURRDIR)
                   }
sub printtail {
               print OUT "</BODY></HTML>\n";
              close (OUT);
              }
