#!/usr/bin/perl use CGI qw/:standard/; #Print out the type of data we're sending back to the client browser. print "Content-type: text/html\n\n"; #Print out the HTML to send to the browser print "\n"; print "\n"; print "\n"; print ""; print "\n"; print "\n"; print "

Tutors Page

"; print "

"; $base_dir = "./"; $final_dir = "tutor"; $dir_name = $base_dir.$final_dir; #Remove file extension, specifically anything following the rightmost ., including the . itself. sub strip_extn{ return substr($_[0],0,rindex($_[0],".")); } $open_ok = opendir(dir_h_File,$dir_name); if ($open_ok) { #if dir not opened, don't bother with other stuff. #print $dir_name." opened OK.
\n"; #Strip out . and .. dir entries... #$tmp = readdir(dir_h_File); #print "Temp= ".$tmp."
"; #$tmp = readdir(dir_h_File); #print "Temp= ".$tmp."
"; $numfiles = 0; #Read dir contents while ($fi = readdir(dir_h_File)) { $fil[$numfiles] = $fi; $numfiles++; } $numfiles || print "No articles found.
"; print "Found ".$numfiles." files!
"; #Sort files alphanumerically, ie by date at start of filename @srt_fil = sort(@fil); #@srt_fil = @fil; $x=0; while ($x < $numfiles) { $str = $srt_fil[$x]; if ($str ne "." && $str ne "..") { print "".strip_extn($str)."
\n"; } $x++; } closedir(dir_h_File); #} || print "Unable to close ".$dir_name."!
\n"; } else {print "No articles found.
";}; #Dir open IF statement ends here print '';