#!/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 "
\"[$icons{dir}[1]]\""; 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 "
\"[$icons{$lookup_ext}[1]]\""; } else { print "
\"[TEXT]\""; } print "See it: $_\n"; if ($has_text) { print "
\"[TEXT]\""; print "See it: $name.txt\n"; } if (!$noexec) { print "
\"[$icons{$lookup_ext}[1]]\""; print "Run it: $_\n"; } print "
\n"; } } } print < END ;