#!/usr/local/bin/perl # Written By: Michael Walters # Innovative Computing Lab # Purpose: Quickly indexes a given directory for use on Netlib # Creates "index" file. # Edit these next two lines $BASE_URL = "ccm"; #leave off trailing '/' $SUB_DIR = "pages/api"; #leave off trailing '/' #example1 $SUB_DIR = "mysub"; #example2 $SUB_DIR = "mysub/anothersub"; #-------------------------------------------------- # ---Do Not Edit Beyond Here--- $PATH = "$BASE_URL/$SUB_DIR"; $THISFILE = "indexdir.pl"; #open the dir for viewing opendir LOCALDIR, "." || die "can't opendir $LocalDir: $!"; @LISTINGS = grep {$_ ne '.' and $_ ne '..'} readdir(LOCALDIR); close LOCALDIR; open INDEX, ">index"; print INDEX "dir $BASE_URL\n"; print INDEX "for Base Directory\n\n"; foreach $listing (@LISTINGS){ $flag = 0; ($name, $ext) = split(".ht", $listing); if($listing ne $THISFILE and $listing ne "index" and $listing ne "MD5" and $ext ne "ml" and $ext ne "m"){ $SIZE = -s $listing; print INDEX "file $PATH/$listing\n"; #retrieve header of file system("head $listing > indexswap.mlw"); open SWAPFILE, "indexswap.mlw"; @HEADER = ; close (SWAPFILE); foreach $HEADER (@HEADER){ if($flag eq "0"){ print INDEX "for $HEADER"; $flag = 1; }else{ print INDEX ", $HEADER"; } } print INDEX "size $SIZE kb\n\n"; print @HEAD; } } close INDEX; system ("rm indexswap.mlw"); system ("chmod 0755 *.*"); system ("chmod 0755 *"); system ("chmod 0700 $THISFILE"); .