#!/usr/local/bin/perl
#Displays the current directory with information about each script.
%icons = ('cgi',['/icons/script.gif','CGI'],
'index',['/icons/script.gif','CGI'],
'html',['/icons/layout.gif','HTML'],
'pl',['/icons/p.gif','PERL'],
'txt',['/icons/text.gif','TEXT'],
'dir',['/icons/folder.gif','DIR'],
'unknown', ['/icons/unknown.gif', 'UNKNOWN']);
my $pwd = `pwd`;
my ($chapter) = $pwd =~ m|([^/]*)$|;
my $dirname = `pwd`;
chomp $dirname;
$dirname =~ s|.*/public||;
$source_name = $dirname;
$source_name =~ s#/scripts(/|$)#/scripts-source$1#;
$exec_name = $dirname;
$exec_name =~ s#/scripts-source(/|$)#/scripts$1#;
print <
Directory Listing of Scripts $chapter
HTML
;
$has_html=0;
foreach (<*>)
{
if(-d $_) {
print "
";
print "Directory: $_\n";
print "
\n";
}
elsif(-f $_ && (-x $_ || /(html|pm|txt)$/) && /[^~\#]$/)
{
$has_text = 0;
open FILE, $_;
($name) = /([^.]+)/;
($ext) = /\.([^.]*)$/;
$command = ;
$desc = ;
$exec = ;
$noexec = ($exec =~ /noexec/i);
($line) = $desc =~ /^#*(.*)/;
if ($ext =~ /^index|txt|s?html$/i) {
$noexec = 1;
}
if ($ext =~ /^shtml$/) {
$line .= "
If the link has the .shtml extension, then the SSIs will be expanded
If the link has the .txt extension, you will see the contents ";
if (-f "$name.txt") {
$has_text = 1;
$line .= "$name.txt";
}
}
close FILE;
$lookup_ext = "unknown";
if (defined ($icons{$ext})) {
$lookup_ext = $ext;
}
if ($ext !~ /^(index|debug|txt)$/i) {
print "
$line\n" if ($line);
if ($ext =~ /^html$/i) {
print "
";
} else {
print "
";
}
print "See it: $_\n";
if ($has_text) {
print "
";
print "See it: $name.txt\n";
}
if (!$noexec) {
print "
";
print "Run it: $_\n";
}
print "
\n";
}
}
}
print <
END
;