#!/usr/bin/perl # $Header:$ # # creates an HTML index for the current directory. # Does not print .* files or any index.* files. # if there is a .comments.txt file, it should # be tab delimited with 2 fields: A filename and comments # the comments are printed next to the listing for the # appropriate filename # # Two types of pseudo-filenames are accepted: # TITLE goes into the title # .NOTE* are sorted(lexically) and printed at the bottom of the table # $Log:$ my( %notes ,%comment); if( open DESC,".comments.txt"){ while(){ chomp; ($name,$desc)=split ( /\t/,$_,2); $comment{$name}=$desc; if( $name =~ /^\.NOTE/){ # in case of name colission, add a space so that # 1) the a note isn't over-written # 2) the order is preserved. while (defined $note{$name}){ $name .= " " }; $note{$name}=$desc; } } }; opendir( PIP,"." ) || die("Can't open current directory!\n"); printf "%s",($comment{"TITLE"}||$ENV{PWD}); print "Start of listing
\n"; print " \n"; foreach $_ ( sort readdir( PIP) ){ unless(/(^index\.)|(^\.)|(^RCS$)/i ){ chomp; print ""; $comment=$comment{$_}; if ( -d $_) { $_ .= "/"; # printf "(dir)\n"; } else{ # printf "(NON-dir)\n"; } printf "\n",$_,$_; @statinfo=stat($_); @chgtime=gmtime(@statinfo[9]); @chgtime[4]++; #month number @chgtime[5] += 1900; # year number printf "\n",@chgtime[5,4,3]; printf "\n",encomma((@statinfo)[7]); printf "\n",$comment; print"\n\n"; } }; foreach $note (sort keys %note){ print "\n"; printf "\n",$note{$note}; print "\n\n"; }; print "
%s%04d/%02d/%02d%s%s
%s
\n"; print "End of listing
\n"; print "\n"; sub encomma{ $num=$_[0]; $x=1; while($num =~ s/(\d)(\d{3})([^\d]|$)/\1,\2\3/){ }; return $num; }; # while( <>){ chomp; printf "%s\n",encomma($_);}