#!/usr/bin/perl use strict; use warnings; ### This program looks at the current directory and then makes a path to all the sub directories. ### Step 1: Create a subroutine with Variables for the program. This includes the following: ### Files, Path and Directories. ### Step 2: make the program list the files and folders of current directory. Push folders into an array ### Step 3: Print Dirs ### Step 4: Recurse if (@ARGV != 1) { print "Usage: perl $0 [PATH/][TO/]DIR\n"; exit; } my $path = $ARGV[0] ; sub list { my $path=$_[0]; #print "DEBUG - listing [$path]\n"; chomp(my @files = `ls -a $path`); my @dirs; foreach(@files) { if (-d "$path/$_" && $_ ne "." && $_ ne ".."){ push (@dirs , "$path/$_"); } } print "-------------------------------------\n"; print "Generating HTML doc for path = [$path]\n"; open(FHOUT, ">", "$path/index.html") or die "Can't open '$path/index.html':$!\n"; print FHOUT ""; print FHOUT "" . "listing:" . ""; print FHOUT "
    \n"; foreach( @files ) { if ($_ ne "index.html" && $_ ne "." && $_ ne "..") { print FHOUT "
  1. "; print FHOUT "Parent"; } if (-d $_) { print FHOUT "  (DIR)"; } print FHOUT "
  2. "; #print FHOUT "
    \n"; } } print FHOUT "
\n"; print FHOUT ""; close(FHOUT); #foreach (@dirs) { # print "$_\n"; #} ####+++++++++++++++ ## Now visit other dirs recursively: foreach (my @dirs) { &list($_); } exit;