#!/usr/bin/perl # # Original script written by Joel Hahn, 2001. #use CGI::Carp qw(fatalsToBrowser); #set up the filename/header data $rawdata="firsted1=1st ed.&firsted2=1st ed.&firsted3=1st ed.&seced1=2nd ed.&seced2=2nd ed.&thirded=3rd ed.&alq=Al Qadim&birth=Birthright&dlance=Dragonlance&dsun=Dark Sun&eberron=Eberron&forg1=Forgotten Realms&forg2=Forgotten Realms&forg3=Forgotten Realms&grey=Greyhawk&kara=Kara Tur&lankh=Lankhmar&myst=Mystara&plane=Planescape&rloft=Ravenloft&sjam=Spelljammer&dnd1=DnD&dnd2=DnD&dnd3=DnD&dnd4=DnD"; #split the raw data into filename=prodline info @pairs = split(/&/, $rawdata); #for each product line, split into filename & product line name, #then go on to print all data for that line $k=0; $j=0; foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $file{$k} = $name; $prodline{$k} = $value; # Open the relevant data file, dump all the data into the @LINES array open(FILEDAT,"$file{$k}.dat") || die "Can't Open $file{$k}.dat: $!\n"; @LINES=; close(FILEDAT); $SIZE=@LINES; # Manipulate the data, crunch the numbers, output the results for ($i=0;$i<=$SIZE-1;$i++) { $_=$LINES[$i]; ($prodcode, $prodname, $votes, $rate, $ratenums)= split(/\|/, $_, 5); if ($rate==0) { $avg=0; } else { $rawavg=$rate/$votes; $exp=2; $avg= sprintf("\%.${exp}f", $rawavg); } if ($avg>=8.50 and $votes>=10) { $BESTDATA[$j]="$avg / $votes $prodname ($prodline{$k})
\n|$ratenums"; $j++; } elsif ($avg<=3.00 and $votes>=10) { $WORSTDATA[$jj]="$avg / $votes $prodname ($prodline{$k})
\n|$ratenums"; $jj++; } } } #open(COUNT,">$RATE{$k}.dat") || die "Could not open $RATE{$k}.dat: $!\n"; #print COUNT "$newline"; # Start printing the output to the screen print "Content-Type: text/html\n\n"; print "Best & Worst *D&D Products\n"; print "\n"; print "

Best & Worst *D&D Products, Sorted By Ratings

\n"; #@date = localtime(time); #$date[4]++; #$modyear=$date[5] #if (length($modyear)==3) { # $modyear=substr($modyear,1,2); #} #print "As of: $date[4]\/$date[3]\/$modyear\n"; ($sec,$min,$hour,$modmday,$modmon,$modyear,$wday,$yday,$isdst) = localtime(time); $modmon++; if (length($modyear)==3) { $modyear=substr($modyear,1,2); } print "(As of: $modmon\/$modmday\/$modyear)\n"; print "
\n"; print "

The Top Products
\n"; print "As measured by average ratings by respondents to the unofficial *D&D Product Survey.
\n"; print "Only products with at least 10 votes and an average rating of 8.5 or higher were eligible.\n"; print "

\n"; print "

Jump to the Worst products list\n"; print "

\n"; print "\n"; print "\n"; @outdata = sort {$b <=> $a} @BESTDATA; $j=1; foreach $odata (@outdata) { ($main, $rnums) = split(/\|/, $odata); print "\n"; } # Finish up the best results table print "
Rank Rating / Votes Product Name
#$j $main"; $j++; #$_=$rnums; #($r0, $r1, $r2, $r3, $r4, $r5, $r6, $r7, $r8, $r9, $r10)= split(/\,/, $_, 11); #print "0:$r0  \;\n"; #print "1:$r1  \;\n"; #print "2:$r2  \;\n"; #print "3:$r3  \;\n"; #print "4:$r4  \;\n"; #print "5:$r5  \;\n"; #print "6:$r6  \;\n"; #print "7:$r7  \;\n"; #print "8:$r8  \;\n"; #print "9:$r9  \;\n"; #print "10:$r10 \n"; print "
\n"; print "

\n"; print "


\n"; print "View the complete ratings.
\n"; print "Go Rate the products.
\n"; print "Return to the ratings index page.\n"; print "

\n"; print "


\n"; print "

Bottom-Feeders: The Worst Products
\n"; print "As measured by average ratings by respondents to the unofficial TSR Product Survey
\n"; print "Only products with at least 10 votes and an average rating of 3.0 or lower were eligible\n"; print "

\n"; print "

Jump to the Best products list\n"; print "

\n"; print "\n"; print "\n"; @outdata = sort {$b <=> $a} @WORSTDATA; foreach $odata (@outdata) { ($main, $rnums) = split(/\|/, $odata); print "\n"; } # Finish up the worst results table & the page print "
Rank Rating / Votes Product Name
#$jj $main"; $jj--; #$_=$rnums; #($r0, $r1, $r2, $r3, $r4, $r5, $r6, $r7, $r8, $r9, $r10)= split(/\,/, $_, 11); #print "0:$r0  \;\n"; #print "1:$r1  \;\n"; #print "2:$r2  \;\n"; #print "3:$r3  \;\n"; #print "4:$r4  \;\n"; #print "5:$r5  \;\n"; #print "6:$r6  \;\n"; #print "7:$r7  \;\n"; #print "8:$r8  \;\n"; #print "9:$r9  \;\n"; #print "10:$r10 \n"; print "
\n"; print "

\n"; print "


\n"; print "View the complete ratings.
\n"; print "Go Rate the products.
\n"; print "Return to the index page\n"; print "";