#!/usr/bin/perl

#Written by Joab Jackson, joabj.com
#This selection collects file names from the directory

print "Enter Directory to be listed (\".\" for current directory):";
chomp($directory = <STDIN>);
opendir( DIR, $directory);
@files = readdir(DIR);
closedir(DIR);

#This section create a file to write the filenames to

print "Enter new file name for this directory listing:";
chomp($FileName = <STDIN>);
die "This $Filename already exists. Please delete.\n"
		if -e $filename;
open FILE, ">$FileName" or die $!;


print FILE "<html>\n";
print FILE "<head>\n";
print FILE "<\/head>\n";
print FILE "<body>\n";
print FILE "<p><p><p>\n";
print FILE "<ul>\n";

foreach $file (@files) {
	if ($file eq '.'){
	next;
	} elsif ($file eq '..'){
	next;
	}else {
	print FILE "<li> <a href=$file>$file<\/a><\/li>\n";
				}

				}

print FILE "<\/ul>\n";
print FILE "<\/body>\n";
print FILE "<\/html>\n";
close FILE;

