#!/usr/bin/perl require "cgi-lib218.pl"; print "Content-type: text/html\n"; print "\n"; print "WXYC Playlist Formatting and Reporting Tool: Results"; # This procedure (from cgi-lib218.pl...see require statement at the # top of the file) reads in the string of name/value information and # parses it out into the associative array ValueOf. Afterwards, all # form values can be referred to as $ValueOf{'name'}, where 'name' # is the name of the form variable. &ReadParse(*ValueOf); $startdate = $ValueOf{'startmonth'}." ".$ValueOf{'startday'}.", ".$ValueOf{'startyear'}; $enddate = $ValueOf{'endmonth'}." ".$ValueOf{'endday'}.", ".$ValueOf{'endyear'}; # Format end-of-line characters. $ValueOf{'topslist'} =~ s/ /\n/g; $ValueOf{'addslist'} =~ s/ /\n/g; # Format special charcters (single quotes). $ValueOf{'topslist'} =~ s/³/'/g; $ValueOf{'topslist'} =~ s/²/'/g; $ValueOf{'topslist'} =~ s/¹/'/g; $ValueOf{'topslist'} =~ s/Ò/'/g; $ValueOf{'topslist'} =~ s/Õ/'/g; $ValueOf{'topslist'} =~ s/Ó/'/g; $ValueOf{'addslist'} =~ s/³/'/g; $ValueOf{'addslist'} =~ s/²/'/g; $ValueOf{'addslist'} =~ s/¹/'/g; $ValueOf{'addslist'} =~ s/Ò/'/g; $ValueOf{'addslist'} =~ s/Õ/'/g; $ValueOf{'addslist'} =~ s/Ó/'/g; @lines = split (/\n/, $ValueOf{'topslist'}); # Shift array over so first line is $lines[1], second line is $lines[2], etc. unshift (@lines, ""); # Initialize line number counter before looping through each line. $line_number = 0; for $index (1..$#lines) { $line_number++; # Strip '$line' of beginning and ending sets of double quotes. $lines[$index] =~ s/^"//; $lines[$index] =~ s/"$//; # Then put the four data components of '$line' into an array, # removing all comma delimiters and extra double quotes in the process. @lineparts = split (/","/, $lines[$index]); # Replace old '$line' with a cleaner presentation of the first three data fields. $lines[$index] = $lineparts[0]." - ".$lineparts[1]." (".$lineparts[2].")"; # Store fourth data field in a separate array for easy referencing. $PlaysReceivedByReleaseNumber[$line_number] = $lineparts[3]; } # Set by the user in the HTML form, the ceiling is the maximum # number of releases that can be listed on the final playlist. $ceiling = $ValueOf{'maximum_tops'}; # Since it is possible # that this user-defined cutoff point occurs in the middle of a group of # releases that all received the same number of plays, we compare the # number of plays received by the last release to "make the cutoff" and # the number of plays received by the first release to "miss the cutoff". # If these numbers are the same, we throw out all releases that received # that many plays. If they are different, we use that exact cutoff point. while ($PlaysReceivedByReleaseNumber[$ceiling] == $PlaysReceivedByReleaseNumber[$ceiling+1]) { $ceiling = $ceiling - 1; } print "

WXYC's Top $ceiling Records from $startdate to $enddate

"; open MAIL, "|mail rosst\@email.unc.edu"; print MAIL "WXYC's Top $ceiling Records from $startdate to $enddate\n"; close MAIL; print "\n
\n"; print "\n"; print "\n"; print "\n"; print "\n"; $netstats = $ValueOf{'internet'}; print "\n"; print "\nRank (Plays) Artist - \"Title of CD/LP/EP/7-inch\" (RECORD LABEL)
\n"; print "\n"; print "-----------------------------------------------------------------------
\n"; print "\n"; print "\n"; $PlaysReceivedByReleaseNumber[0] = 0; for $line_num (1..$ceiling) { $num_plays = $PlaysReceivedByReleaseNumber[$line_num]; if ($line_num < 10) { $lines[$line_num] = " ".$line_num." (".$num_plays.") ".$lines[$line_num]; } else { $lines[$line_num] = $line_num." (".$num_plays.") ".$lines[$line_num]; } $fieldname = "PlaylistLine".$line_num; $fieldvalue = $lines[$line_num]; print "$lines[$line_num]
\n"; #print OUTFILE "$lines[$line_num]\n"; print "\n"; } @lines2 = split (/\n/, $ValueOf{'addslist'}); print "

Here's a list of recently added releases that didn't make this week's chart:

"; #print OUTFILE "\nHere's a list of recently added releases that didn't make this week's chart:\n\n"; $add_num = 0; foreach $line (@lines2) { $line =~ s/^"//; $line =~ s/"$//; @lineparts = split (/","/, $line); if ($lineparts[3] < $PlaysReceivedByReleaseNumber[$ceiling]) { $add_num++; $fieldname = "AddLine".$add_num; $line = $lineparts[0]." - ".$lineparts[1]." (".$lineparts[2].")"; print "$line
\n"; print "\n"; } } print "

\n"; print < FORM_END print "";