#!/usr/local/bin/perl ########################################################################################################### # # # WSN story indexer # # by Doug Letterman # # # # This script periodically scans all the files and directories in the pubs/wsn # # directory and makes an HTML index called dir.html # # # # # ########################################################################################################### # Declare the variables $startingDir = "/www/sites/nyu.edu/htdocs/pages/pubs/wsn"; $startingURL = ""; $dirFile = "/www/sites/nyu.edu/htdocs/pages/pubs/wsn/dir.html"; open (DIRFILE, ">$dirFile") || warn "Could not open $archivedfilename\n"; print DIRFILE "\n\nWSN Index"; print DIRFILE "\n\n"; print DIRFILE "\n\n"; &createBranching($startingDir, $startingURL); #Here are the subroutines sub createBranching { my($path, $URL) = @_; opendir(DIR, $path); ## print "\nopening: $path\n"; # For scoping so that the values stay to this subroutine my(@files) = readdir(DIR); closedir(DIR); foreach $f (@files) { my $myPath = $path . "/" . $f; ##print "\nScanning: $myPath"; if (-f $myPath) { my $myURL = $URL . $f; ## print "\n
$myURL"; print DIRFILE "\n
$myURL"; } elsif (-d $myPath) ## && $f =~ (m/[0-9]+/)) { my $myURL = $URL . $f . "/"; &createBranching($myPath, $myURL); } } } close (DIRFILE); # EOF