#!/usr/bin/perl #-------------: Edit Text files #-------------: Jan-2004, Harley H. Puthuff #-------------: ©2004, DigiDentist use Cgi; #-------Local properties, methods: $extension = '.txt'; # default text file extension @textFiles = (); # list of text files within path sub put ($) {print STDOUT shift(),"\n"} #-------Main entry & dispatch: $extension = lc(".$ENV{QUERY_STRING}") if ($ENV{QUERY_STRING} ne ''); $extension = ".txt" if (($extension eq ".cgi") || ($extension eq ".pl")); $cgi = new Cgi; $cgi->headers; if (exists $cgi->{Update}) {updateFiles()} else { gatherFiles(); displayFiles(); } exit 0; #-------Gather up all text file names in the directory: sub gatherFiles { my @files; opendir(DIR,".") || return; @files = readdir DIR; foreach (@files) {push @textFiles,$_ if (index($_,$extension) != -1)} closedir DIR; } #-------Display the styles: sub displayStyles { print STDOUT <<"ETX"; ETX } #-------Display editing form for all text files: sub displayFiles { my ($files,$i,$filename,$line,$col,$row,$depth); $files = scalar @textFiles; put qq||; put qq|
|; put qq|