#!/usr/local/bin/perl -w # fallcourses.cgi # Program to display fall course information for Community Education # After you publish a revised page you have to adjust the properties to 755 use strict; # ******************** configuration variables # ********************************************************************** my ($debugit) = 0; # 1 prints variable values at # specific points for debugging my ($runline) = "http://alamo.nmsu.edu/comed/fallcourses.cgi"; my ($datafile) = "/web/site/comed/tbl-FallCourse.txt"; my ($yearFallfile) = "/web/site/comed/yearFall.txt"; my ($webpath) = "http://alamo.nmsu.edu/community"; #******************** variable declarations # ********************************************************************** my ($yearFall) = ""; print "Content-type: text/html\n\n"; # ****************** Main Routine ************************** # *********************************************************** if ($debugit) { print "Beginning of Main Program
"; } print_header(); if ($debugit) { print "Determine user input
"; } if ($debugit) { print "ARGV = $ARGV[0]
"; } if ($debugit) { print "Display data based on user input
"; } read_yearFall(); if ($ARGV[0] ne "") { if ($debugit) { print "ARGV = $ARGV[0]
"; } if ($debugit) { print "go to print course info routine
"; } print_courseinfo(); } else { print_courselist(); } print_footer(); # **************** Begin subroutines *********************** # *********************************************************** sub print_courseinfo { my ($fileinfo) = ""; my (@lines) = ""; my ($line) = ""; # my (@fields) = ""; my (@temp) = ""; my ($i) = ""; my $numrecords = ""; my (@records) = ""; my ($record) = ""; my (@CourseID) = ""; my (@CourseTitle) = ""; my (@Instructor) = ""; my (@Fee); my (@MaterialsCost) = ""; my (@Dates) = ""; my (@Day1stChoice) = ""; my (@Time) = ""; my (@Location) = ""; my (@CourseDescription) = ""; my (@EvalResults) = ""; my (@AgeRange) = ""; my (@MinStudents) = ""; my (@MaxStudents) = ""; my (@CurrentCount) = ""; my (@PreferredFacility) = ""; my (@Supplies) = ""; my (@Equipment) = ""; my (@WaiverNeeded) = ""; my (@Cancelled) = ""; my (@HoursPerWeek) = ""; my (@StartDate) = ""; my (@EndDate) = ""; my (@Category) = ""; my ($CurCategory) = ""; if ($debugit) { print "Open data file
"; } # print "
"; if (open FH, "$datafile") { if ($debugit) { print "data file successfully opened
"; } if ($debugit) { print "Read data file
"; } read FH, $fileinfo, 65000; @lines = split /^/m, $fileinfo; $i = 0; foreach $line (@lines) { if ($debugit) { print "$line
"; } $temp[$i] = $line; $i++; } $numrecords = $i; if ($debugit) { print "There are $numrecords records.
"; } @records = sort { (split /\|/, uc($a), 24)[23] cmp (split /\|/, uc($b), 24)[23] || (split /\|/, uc($a), 24)[1] cmp (split /\|/, uc($b), 24)[1] || (split /\|/, uc($a), 24)[0] cmp (split /\|/, uc($b), 24)[0] } @temp; if ($debugit) { print "There are $numrecords records.
"; } $i = 0; foreach $record (@records) { $i++; ($CourseID[$i], $CourseTitle[$i], $Instructor[$i], $Fee[$i], $MaterialsCost[$i], $Dates[$i], $Day1stChoice[$i], $Time[$i], $Location[$i], $CourseDescription[$i], $EvalResults[$i], $AgeRange[$i], $MinStudents[$i], $MaxStudents[$i], $CurrentCount[$i], $PreferredFacility[$i], $Supplies[$i], $Equipment[$i], $WaiverNeeded[$i], $Cancelled[$i], $HoursPerWeek[$i], $StartDate[$i], $EndDate[$i], $Category[$i]) = split /\|/, $record; if ($debugit) { print "$Category[$i], $CourseID[$i], $CourseTitle[$i]
"; } if ($CourseID[$i] eq $ARGV[0]) { # print "

$yearFall Fall Courses & Instructors

"; #print "
"; #print "
Back to Course Listing"; #print "
"; print "

$CourseTitle[$i]

"; print "

Instructor: $Instructor[$i]

"; print "

Course Description: $CourseDescription[$i]


"; print ""; print ""; # print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print "
Course ID: $CourseID[$i]
When:$Dates[$i], $Day1stChoice[$i], $Time[$i]
Where:$Location[$i]
What Age:$AgeRange[$i]
Min. Students:$MinStudents[$i]
Max. Students:$MaxStudents[$i]
Tuition:$Fee[$i]
"; } } } else { print "could not open data file
"; } # print "
"; } sub print_courselist { my ($fileinfo) = ""; my (@lines) = ""; my ($line) = ""; # my (@fields) = ""; my (@temp) = ""; my ($i) = ""; my $numrecords = ""; my (@records) = ""; my ($record) = ""; my (@CourseID) = ""; my (@CourseTitle) = ""; my (@Instructor) = ""; my (@Fee); my (@MaterialsCost) = ""; my (@Dates) = ""; my (@Day1stChoice) = ""; my (@Time) = ""; my (@Location) = ""; my (@CourseDescription) = ""; my (@EvalResults) = ""; my (@AgeRange) = ""; my (@MinStudents) = ""; my (@MaxStudents) = ""; my (@CurrentCount) = ""; my (@PreferredFacility) = ""; my (@Supplies) = ""; my (@Equipment) = ""; my (@WaiverNeeded) = ""; my (@Cancelled) = ""; my (@HoursPerWeek) = ""; my (@StartDate) = ""; my (@EndDate) = ""; my (@Category) = ""; my ($CurCategory) = ""; if ($debugit) { print "Open data file
"; } print "

$yearFall - Fall Courses, Dates, & Instructors


"; print ""; if (open FH, "$datafile") { if ($debugit) { print "data file successfully opened
"; } if ($debugit) { print "Read data file
"; } read FH, $fileinfo, 65000; @lines = split /^/m, $fileinfo; $i = 0; foreach $line (@lines) { if ($debugit) { print "$line
"; } $temp[$i] = $line; $i++; } $numrecords = $i; if ($debugit) { print "There are $numrecords records.
"; } @records = sort { (split /\|/, uc($a), 24)[23] cmp (split /\|/, uc($b), 24)[23] || (split /\|/, uc($a), 24)[1] cmp (split /\|/, uc($b), 24)[1] || (split /\|/, uc($a), 24)[0] cmp (split /\|/, uc($b), 24)[0] } @temp; if ($debugit) { print "There are $numrecords records.
"; } $i = 0; foreach $record (@records) { $i++; ($CourseID[$i], $CourseTitle[$i], $Instructor[$i], $Fee[$i], $MaterialsCost[$i], $Dates[$i], $Day1stChoice[$i], $Time[$i], $Location[$i], $CourseDescription[$i], $EvalResults[$i], $AgeRange[$i], $MinStudents[$i], $MaxStudents[$i], $CurrentCount[$i], $PreferredFacility[$i], $Supplies[$i], $Equipment[$i], $WaiverNeeded[$i], $Cancelled[$i], $HoursPerWeek[$i], $StartDate[$i], $EndDate[$i], $Category[$i]) = split /\|/, $record; if ($debugit) { print "$Category[$i], $CourseID[$i], $CourseTitle[$i]
"; } } for ($i = 1; $i <= $numrecords; $i++) { if ($debugit) { print "$i is $Category[$i]
"; } if ($CurCategory ne $Category[$i]) { $CurCategory = $Category[$i]; print ""; print "

$CurCategory

"; #print "

Course Title

"; print ""; } #print ""; #print ""; print ""; #print ""; print ""; print ""; } print "
Course Title: 
"; print "$CourseTitle[$i]Instructor: $Dates[$i]$Instructor[$i]
"; } else { print "could not open data file
"; } print ""; } sub print_header { print << "ENDOFHEADER"; Alamogordo Community Education - NMSU at Alamogordo

Search NMSU-A:


ENDOFHEADER } sub print_footer { print << "ENDOFFOOTER";

Community Education Links

Contact Information

  • Personnel: Janis McWilliams or Joan Griggs
  • Location: NMSU-A, 2400 North Scenic Drive, CB 401
  • Phone: 575.439.3842/3626
  • FAX: 575.439.3805
  • Email: Community Education
ENDOFFOOTER } sub read_yearFall { if ($debugit) { print "Open data file
"; } if (open FH, "$yearFallfile") { if ($debugit) { print "data file successfully opened
"; } if ($debugit) { print "Read data file
"; } read FH, $yearFall, 20; close FH; } }