#!/usr/local/bin/perl use lib "/home/scsfac/downeyt/public/scripts"; use CGIBook::Error; use CGILib; use DB_File; my %query = get_query(); my %selected; $selected{$query{class}} = "selected"; $basePath = "/home/scsfac/downeyt/notes/"; my %monthArr = qw(january 0 february 1 march 2 april 3 may 4 june 5 july 6 august 7 september 8 october 9 november 10 december 11); $strRetrieve = "Retrieve"; print < Show All Class Notes
Class:
HTML ; $showClass = $defaultClass; if ($query{class}) { $showClass = $query{class}; } if ($showClass) { print_cal($showClass); } print < HTML ; sub print_cal { ($courseName) = @_; chomp $courseName; my %hash = (); my $db = tie %hash, "DB_File", "$basePath$courseName.db", O_CREAT | O_RDWR or die "Could not open $basePath$courseName.db: $!"; my $fd = $db->fd; open DBM, "+<&$fd" or die "Could not dup DBM: $!"; flock DBM, LOCK_EX; undef $db; %calMonth=(); foreach $date (sort sort_by_month_day keys %hash) { ($month, $day) = split(/\./,$date); $calMonth{$month} .= ":$day"; } print "\n"; print "\n"; $align = 0; foreach $month (sort sort_by_month keys %calMonth) { print "\n"; @day = split (/:/,$calMonth{$month}); shift @day; sort {$a <=> $b} @day; $pos = 0; foreach (@day) { if ($pos%2 == 0) { print ""; } $pos++; if ($align) { print "\n"; $align =0; $pos++; } my ($heading, $content) = split("$;",$hash{"$month.$_"}); print "\n"; if ($pos%2 == 0) { print ""; } } $align = ($pos%2 != 0); } print "
$courseName
$month
 \n"; print "$_: $heading\n"; print "
$content
\n"; print "
"; } sub sort_by_month_day { my ($montha, $daya) = split(/\./,$a); my ($monthb, $dayb) = split(/\./,$b); $montha cmp $monthb || $daya <=> $dayb; } sub sort_by_month { $monthArr{lc $a} <=> $monthArr{lc $b}; }