#!/usr/local/bin/perl #---------------------------------------------------------- # File: list.cgi # Purpose: To create a listbox of all files ending in .csv # Input: none # Output: HTML form #---------------------------------------------------------- #Force variable declaration use strict; #Declare Variables my @files; #List of all files in the directory my $file; #Looping variable #Print content/type header print "Content-type: text/html\n\n"; #Print opening HTML print "\n"; print "Choose a class\n"; print "\n"; print "Please select a class to view

\n"; #Open directory handle opendir(DIR, ".") || die "Error! Cannot open directory"; #Get all the files ending in *.csv while($file = readdir(DIR)) { if ($file =~ /\.csv\Z/) { push(@files, $file); } } #Print input form print "
\n"; #Verify that at least one file exists if (@files > 0) { #Print listbox print "\n"; print "  \n"; } else { #Display error msg print "There are no files to view\n"; } print "
\n"; #Print closing HTML print "\n"; print "\n";