#!/usr/bin/perl ### Display all (or selected) files in directory. (+++ subdirs, too?) ### Also display TITLE/ABSTRACT info. ### head.txt and tail.txt are also displayed. ######################################################################## ### Copyright (C) Tripodics.com ### Author: Bruce A. Martin ### File Name: display.pl ### Versions: ### 0.3 (Don't show .pl source code.) ### 0.2 bam:2004/08/03 Add PNG, also link for DIR. ### 0.1 bam:2004/02/22 Extract description from HTML ### 0.0 bam:2003/11/20 ######################################################################### use strict; use CGI qw/:standard/; print header; # html format is permitted to output. my $NL = "\n"; my $Q = '"'; ### Get parameters from html form. # my %in_para; foreach (param()){ $in_para{$_} = join " ", param($_); # Multiple-values (checkbox) joined with blanks. } #### Set prefix to path. #### my $name = $ENV { 'COMPUTERNAME' } ; my $path = ""; #### Set file names. #### my $DIRNAME = $in_para{DIRNAME}; my $dirname = $path . "./"; if ($DIRNAME) { $dirname = $path . $DIRNAME . "/"; } my $MAXLINES = $in_para{MAXLINES}; my $maxlines = $MAXLINES; if ($maxlines < 1) { $maxlines = 10; } my $head = $path . "head.html"; my $tail = $path . "tail.html"; ### Main processing # &show( $head ); &showdir( $dirname ); print "
TAIL:
"; &show( $tail ); print "
"; my $s=''; $s .= '
'; $s .= '
Directory.'; $s .= '
lines.'; $s .= '
'; $s .= '
'; print $s; exit; ######## The following subroutines are from the Tripodics Library. ######## #### Copyright 1996-2002 by Tripodics, All Rights Reserved. #### #### Tripodics Computing Service, POBox 456 Middle Island, NY 11953 #### #+++ (Nonexclusive usage granted to PhDsigns, Bay Shore, NY.) +++# ############################################################################ ################################### show.pl # Print contents of an HTML file. # sub show( $f ) { my $f = $path . @_[0]; open(F,"$f") or return 0; while(){ print; } close(F); } sub showdir( $d ) { my $d = $path . @_[0]; my @allfiles; opendir(D,$d) or return 0; @allfiles = grep !/^\./, readdir D; closedir D; print "#### allfiles= @allfiles
"; print "