# FILE hockmcomb.pl  working copy  running time  sec
# fix NC standings to include /PL/ for playoffs /NC|PL/ FIXED 
#============= CREATE SCORES PAGE ===================
$scofile='HOCKsco0102.txt'; 
open (SCORES,"<$scofile") || die "Can't open $scorefile $!";
open (SCORESHTML, ">hockscores0102.html");
print SCORESHTML "<html><head><title>CIAU Hockey scores 2001-02</title>
</head>
<body>
<Font Face=Arial size=-1>\n
<big><b>Hockey Scores 2001-02</b></big>";

while (<SCORES>) { 
	($date,$Tm1,$Sco1,$Tm2,$Sco2,$GmType,$Notes) = split(':',$_);	

  ### Flag any reversed score, stops program, prints line to warn 
if ($Sco1 < $Sco2) { 
die
print "$date $Tm1 $Sco1 $Tm2 $Sco2 $GmType $Notes";
}
                                        # dispose of heading in data file
if ($date =~ /CIAU/) {
print SCORESHTML "<big><b>$date</b></big>\n";   next;
}
                          # print date if alone on datafile row
if  ($Tm1 le " ") {   
  print SCORESHTML "<br><b>$date</b>\n";
                 }              
                          #print score lines without dates
else {                    
print SCORESHTML "<br>$Tm1 $Sco1 $Tm2 $Sco2 $GmType $Notes\n";
     }
}
print SCORESHTML "</body></html>"; #close HTML file
close SCORESHTML;

#====================================================
#### TEAM-BY-TEAM SCORES ###
#====================================================

$scofile='HOCKsco0102.txt'; 
open (SCORES,"<$scofile") || die "Can't open $scorefile $!";
open (TEAMDATA, ">hockteams0102.html");
print TEAMDATA "
<HTML><HEAD>

<STYLE>
TD {font: 10pt arial}
</STYLE>
</head>
<BODY bgcolor=white LINK=\"\#0000ff\" VLINK=\"\#0000ff\"> <Font Face=Arial Size=-1>

<TABLE border=0  cellspacing=4 cellpadding=4>
<TR>
<TD  colspan=4 align=center  BGCOLOR=\"\#d2d5e1\">
<B>2001-02 Hockey Scores by Team</B><small>

<TR>
<TD  NOWRAP align=center valign=top BGCOLOR=\"\#d2d5e1\">
<B>Atlantic</B><Br><B>AUS</B><Br>
<A HREF=\"\#Acadia\">Acadia</A><Br>
<A HREF=\"\#Dalhousie\">Dalhousie</A><Br>
<A HREF=\"\#Saint Mary's\">Saint Mary's</A><Br>
<A HREF=\"\#Moncton\">Moncton</A><Br>
<A HREF=\"\#StFX\">StFX</A><Br>
<A HREF=\"\#St. Thomas\">St. Thomas</A><Br>
<A HREF=\"\#UNB\">UNB</A><Br>
<A HREF=\"\#UPEI\">UPEI</A><Br>

<TD  align=center valign=top BGCOLOR=\"\#d2d5e1\">
<B>OUA</B><Br><B>QIFC</B><Br>
<A HREF=\"\#Concordia\">Concordia</A><Br>
<A HREF=\"\#McGill\">McGill</A><Br>
<A HREF=\"\#Ottawa\">Ottawa</A><Br>
<A HREF=\"\#UQTR\">UQTR</A><Br>
<A HREF=\"\#Queen's\">Queen's</A><Br>
<A HREF=\"\#RMC\">RMC</A><Br>
<A HREF=\"\#Ryerson\">Ryerson</A><Br>
<A HREF=\"\#Toronto\">Toronto</A><Br>

<TD align=center valign=top BGCOLOR=\"\#d2d5e1\"><B> OUA </B><Br>
<B>OUA</B><Br>
<A HREF=\"\#Brock\">Brock</A><Br>
<A HREF=\"\#Guelph\">Guelph</A><Br>
<A HREF=\"\#Laurier\">Laurier</A><Br>
<A HREF=\"\#York\">York</A><Br>
<A HREF=\"\#Lakehead\">Lakehead</A><Br>
<A HREF=\"\#Waterloo\">Waterloo</A><Br>
<A HREF=\"\#Western\">Western</A><Br>
<A HREF=\"\#Windsor\">Windsor</A><Br>

<TD  align=center valign=top BGCOLOR=\"\#d2d5e1\">
<B>CanWest</B><Br><B>CWUAA</B><Br>
<A HREF=\"\#Brandon\">Brandon</A><Br>
<A HREF=\"\#Manitoba\">Manitoba</A><Br>
<A HREF=\"\#Regina\">Regina</A><Br>
<A HREF=\"\#Saskatchewan\">Saskatchewan</A><Br>
<A HREF=\"\#Alberta\">Alberta</A><Br>
<A HREF=\"\#Calgary\">Calgary</A><Br>
<A HREF=\"\#Lethbridge\">Lethbridge</A><Br>
<A HREF=\"\#UBC\">UBC</A><Br>
</TR></TD></TABLE>
&nbsp;
";



@TeamName = ("Acadia", "Dalhousie", "Saint Mary's", "Moncton",
"StFX", "St. Thomas", "UNB", "UPEI",
"Ottawa", "Concordia", "McGill", "UQTR", 
"Queen's", "RMC", "Ryerson", "Toronto", 
"Brock", "Guelph", "Laurier", "York", 
"Lakehead", "Waterloo", "Western", "Windsor", 
"Brandon", "Manitoba", "Regina", "Saskatchewan", 
"Alberta", "Calgary", "Lethbridge", "UBC",);

foreach $team (@TeamName) {
open (TEAMDATA, ">>hockteams0102.html");

print TEAMDATA "<p><dd><big><big><A NAME=\"$team\">$team</A></big></big>\n";

open (SCORES,"<$scofile") || die "Can't open $scorefile $!";
while (<SCORES>) { 
	($Date,$Tm1,$Sco1,$Tm2,$Sco2,$GmType,$Notes) = split(':',$_);	
   
if  ($Tm1 eq $team || $Tm2 eq $team)   {   
  print TEAMDATA "<br>$Date $Tm1 $Sco1 $Tm2 $Sco2 $GmType $Notes\n";
     }
}
}
print TEAMDATA "</body></html>";


#====================================================
#### CREATING STANDINGS MDA file ###
#====================================================


$scofile='HOCKsco0102.txt'; 
 open (HOCKMDA, ">hockstand.txt") || die "Can't open hockstand.txt $!"; 
print HOCKMDA "";

@TeamName = ("Acadia", "Dalhousie", "Saint Mary's", "Moncton",
"StFX", "St. Thomas", "UNB", "UPEI",
"Ottawa", "Concordia", "McGill", "UQTR", 
"Queen's", "RMC", "Ryerson", "Toronto", 
"Brock", "Guelph", "Laurier", "York", 
"Lakehead", "Waterloo", "Western", "Windsor", 
"Brandon", "Manitoba", "Regina", "Saskatchewan", 
"Alberta", "Calgary", "Lethbridge", "UBC",);

foreach $team (@TeamName) {
  open (SCORES,"<$scofile") || die "Can't open $scorefile $!";
  open (HOCKMDA, ">>hockstand.txt") || die "Can't open hockstand.txt $!"; 

            # initialize counts
$teamwins=0; $teamlosses=0; $teamgp=0; $teamties=0; 
$pfor=0; $Against=0; $WLpct=0; $Margin=0; $Pts=0; 
$WLpct=0; $pfpg=0; $papg=0; $mgp=0;  $olosses=0;  
$NCwins=0;  $NClosses=0;  $NCties=0;
$CISwins=0; $CISlosses=0; $CISties=0;
$EXwins=0;  $EXlosses=0;  $EXties=0;
$OAwins=0;  $OAlosses=0;  $OAties=0;

              # while reading SCORES (HOCKsco0102.txt) line-by-line 
              # parse it at colons : into standings variables  
while (<SCORES>) {    
	($date,$Tm1,$Sco1,$Tm2,$Sco2,$GmType,$Notes) = split(':',$_);	


                   #-------------------------------------------
                   # BEGIN calculation of standings variables.
                   #-------------------------------------------
if ($Tm1 eq $team and $GmType eq "" and $Notes !~ /TIE/ )   { 
                                     # selects Conference only
++$teamgp; ++$teamwins;             # counts name in winner column
$pfor = ($pfor + $Sco1);             # adds winner's score to FOR 
$Against = ($Against + $Sco2);       # adds loser's score to AGAINST
}
elsif ($Tm2 eq $team && $GmType eq "" && $Notes !~ /TIE/ )   {
++$teamgp; ++$teamlosses;           # counts name in loser column 
$pfor = ($pfor + $Sco2);             # adds loser's score to FOR
$Against = ($Against + $Sco1);       # adds winner's score to AGAINST 
}
elsif (($Tm2 eq $team || $Tm1 eq $team) && $GmType eq "" && $Notes =~ /TIE/ )   {
++$teamgp; ++$teamties; 
$pfor = ($pfor + $Sco1);             # adds tie score to FOR
$Against = ($Against + $Sco1);       # adds tie score to AGAINST 
}

         #============== All CIS =================
if (($Tm1 eq $team) and ($GmType =~/NC|PL/) and ($Notes !~ /TIE/ ))   { 
++$NCwins;
}
elsif (($Tm2 eq $team) and ($GmType =~/NC|PL/) and ($Notes !~ /TIE/ ))   {
++$NClosses;
}
elsif (($Tm2 eq $team || $Tm1 eq $team) and $GmType =~/NC|PL/ and $Notes =~ /TIE/ )   {
++$NCties;
}
$CISwins = ($teamwins + $NCwins);    
$CISlosses = ($teamlosses + $NClosses);    
$CISties = ($teamties + $NCties);    
        #============== OVERALL =================
if (($Tm1 eq $team) and ($GmType =~ /EX/) and ($Notes !~ /TIE/ ))   { 
++$EXwins;
}
elsif (($Tm2 eq $team) and ($GmType =~ /EX/) and ($Notes !~ /TIE/ ))   {
++$EXlosses;
}
elsif (($Tm2 eq $team || $Tm1 eq $team) and $GmType =~ /EX/ and $Notes =~ /TIE/ )   {
++$EXties;
}
$OAwins = ($CISwins + $EXwins) ;    
$OAlosses = ($CISlosses + $EXlosses) ;    
$OAties = ($CISties + $EXties) ;    


         #============== OVERTIME LOSS ====================
if ($Tm2 eq $team && $Notes =~ /OL/) {      # OL Overtime Loss
++$olosses ;


}
         #=================================================

$Margin = ($pfor - $Against);        # Calculates +/- diff
$Pts = (2 * $teamwins) + $teamties + $olosses; 


if ($teamgp == 0) {  #NEW
    $WLpct = 1.000 ; #NEW
}                    #NEW
                                     # calc W/L %, elim div by zero 
elsif ($teamlosses == 0 and $teamties == 0 and $teamgp != 0) {  
$WLpct = 1.000;                          #NEW > > > > > > >
}
else {
$WLpct = ( ($teamwins + ($teamties * .5 )) / $teamgp );
}
if ($teamgp != 0) {
$pfpg = ($pfor / $teamgp);
$papg = ($Against / $teamgp);
$mgp = ($Margin / $teamgp);
}

if ($team =~ /Acadia|Dalhousie|Saint Mary's|Moncton|StFX|
St. Thomas|UNB|UPEI/) {   
   $conf = "aAU";
   }
elsif ($team =~ /Ottawa|Concordia|McGill|UQTR/) {
   $conf = "cOUFE";
   }
elsif ($team =~ /Queen's|RMC|Ryerson|Toronto/) {
   $conf = "dOUME";
   }
elsif ($team =~ /Brock|Guelph|Laurier|York/) {
   $conf = "eOUMW";
   }
elsif ($team =~ /Lakehead|Waterloo|Western|Windsor/) {
   $conf = "fOUFW";
   }
elsif ($team =~ /Brandon|Manitoba|Regina|Saskatchewan/) {
   $conf = "gCWGP";
   }
elsif ($team =~ /Alberta|Calgary|Lethbridge|UBC/) {
   $conf = "hCWW";
   }
}   
# Atlantic: Acadia, Dalhousie, Saint Mary's, Moncton
#           StFX, St. Thomas, UNB, UPEI
# Far East: Ottawa, Concordia, McGill, UQTR 
# Mid East: Queen's, RMC, Ryerson, Toronto 
# Mid West: Brock, Guelph, Laurier, York 
# Far West: Lakehead, Waterloo, Western, Windsor 
# G Plains: Brandon Manitoba Regina Saskatchewan	
# Mountain: Alberta Calgary Lethbridge UBC 

            # END calculation of standings variables for Team.

print HOCKMDA "$team:$conf:$teamgp:$teamwins:$teamlosses:$teamties:$pfor:$Against:$Margin:$Pts:$WLpct:$pfpg:$papg:$mgp:$CISwins:$CISlosses:$CISties:$OAwins:$OAlosses:$OAties\n";
}
close HOCKMDA;

#====================================================
#### SORTING STANDINGS ###
#====================================================

$stanfile='hockstand.txt'; 
open (HOCKMDA, "<hockstand.txt") || die "Can't open $stanfile $!"; 

@mda = <HOCKMDA>; 
@mdasorted = map { $_->[0] }
 sort {
        $a->[2] cmp $b->[2]
||    $b->[10] <=> $a->[10]
||    $b->[11] <=> $a->[11]
||    $b->[14] <=> $a->[14]
||      $a->[1] cmp $b->[1] 
}
map { [ $_, (split /:/, $_,) ] } 
@mda; 

open (STANHTML, ">hockstand0102.html");
print STANHTM "";
open (STANHTML, ">>hockstand0102.html");

open (STANAUS, ">hockstanaus.txt");
open (STANOUAFE, ">hockstanouafe.txt");
open (STANOUAME, ">hockstanouame.txt");
open (STANOUAMW, ">hockstanouamw.txt");
open (STANOUAFW, ">hockstanouafw.txt");
open (STANCWGP, ">hockstancwgp.txt");
open (STANCWW, ">hockstancww.txt");

print STANAUS @mdasorted[0 .. 7];  ##AUS .. begins zero
print STANOUAFE @mdasorted[8 .. 11];  ##OUAFarEast
print STANOUAME @mdasorted[12 .. 15];  ##OUAMidEast
print STANOUAMW @mdasorted[16 .. 19];  ##OUAMidWest
print STANOUAFW @mdasorted[20 .. 23];  ##OUAFarWest
print STANCWGP @mdasorted[24 .. 27];  ##CanWestGPlains
print STANCWW @mdasorted[28 .. 31];  ##CanWestWest

##======================================================
print STANHTML "
<HTML><HEAD><title>HOCKEY Standings 2001-02</title>
<STYLE>
td {font: 10pt arial; text-align:right}
th {font: 10pt arial; font-weight=bold; text-align:right}
</STYLE>
</head>
<BODY bgcolor=white LINK=0000ff VLINK=0000ff> <Font Face=Arial Size=-1>
<TABLE border=0  cellspacing=3 cellpadding=0 bgcolor=white>
<TR>
<TD style=text-align:center colspan=8>
<B>2001-02 Hockey Standings</B></td></TR>
<tr><td style=text-align:left> &nbsp; </td><td colspan=7 bgcolor=#d2d5e1 style=text-align:center>CONFERENCE</td><td colspan=3 bgcolor=#EFCDCC style=text-align:center>All-CIS</td><td colspan=3 bgcolor=#d2d5e1 style=text-align:center>Overall</td></tr>
";
##======================================================
##================AUS=======================
print STANHTML "
<tr><th style=text-align:left> Atlantic </th><th>W </th><th>L </th><th>T </th><th>  F  </th><th>   A </th><th>  P </th><th>Pct </th><th>W </th><th>L </th><th>T </th><th>W </th><th>L </th><th>T </th></tr>";

open (STANAUS, "<hockstanaus.txt");

while (<STANAUS>) { 
	($tm,$tmconf,$tmgp,$tmw,$tml,$tmt,$tmf,$tma,$tmm,$tmpts,$tmpct,$pfg,$pag,$pmg,$CISwins,$CISlosses,$CISties,$OAwins,$OAlosses,$OAties) = split(':',$_);	

$tmpct = sprintf("%.3f", $tmpct);   ## converts to 3 places
$tmpct =~ s/^0/ /g;                 ## replace Leading Zeros

print STANHTML "
<tr><td style=text-align:left>$tm</td>
<td>$tmw</td><td>$tml</td><td>$tmt</td>
<td>$tmf</td><td>$tma</td><td>$tmpts</td>
<td>$tmpct</td>
<td>$CISwins</td><td>$CISlosses</td><td>$CISties</td>
<td>$OAwins</td><td>$OAlosses</td><td>$OAties</td>
</tr>";
}


##================OUAFE=======================

print STANHTML "
<tr><th style=text-align:left> O FarEast </th><th>W </th><th>L </th><th>T </th><th>  F  </th><th>   A </th><th>  P </th><th>Pct </th><th>W </th><th>L </th><th>T </th><th>W </th><th>L </th><th>T </th></tr>";

open (STANOUAFE, "<hockstanouafe.txt");

while (<STANOUAFE>) { 
	($tm,$tmconf,$tmgp,$tmw,$tml,$tmt,$tmf,$tma,$tmm,$tmpts,$tmpct,$pfg,$pag,$pmg,$CISwins,$CISlosses,$CISties,$OAwins,$OAlosses,$OAties) = split(':',$_);	

$tmpct = sprintf("%.3f", $tmpct);   ## converts to 3 places
$tmpct =~ s/^0/ /g;                 ## replace Leading Zeros

print STANHTML "
<tr><td style=text-align:left>$tm</td>
<td>$tmw</td><td>$tml</td><td>$tmt</td>
<td>$tmf</td><td>$tma</td><td>$tmpts</td>
<td>$tmpct</td>
<td>$CISwins</td><td>$CISlosses</td><td>$CISties</td>
<td>$OAwins</td><td>$OAlosses</td><td>$OAties</td>
</tr>";
}


##================OUAME=======================

print STANHTML "
<tr><th style=text-align:left>O MidEast</th><th>W </th><th>L </th><th>T </th><th>  F  </th><th>   A </th><th>  P </th><th>Pct </th><th>W </th><th>L </th><th>T </th><th>W </th><th>L </th><th>T </th></tr>";

open (STANOUAME, "<hockstanouame.txt");

while (<STANOUAME>) { 
	($tm,$tmconf,$tmgp,$tmw,$tml,$tmt,$tmf,$tma,$tmm,$tmpts,$tmpct,$pfg,$pag,$pmg,$CISwins,$CISlosses,$CISties,$OAwins,$OAlosses,$OAties) = split(':',$_);	

$tmpct = sprintf("%.3f", $tmpct);   ## converts to 3 places
$tmpct =~ s/^0/ /g;                 ## replace Leading Zeros

print STANHTML "
<tr><td style=text-align:left>$tm</td>
<td>$tmw</td><td>$tml</td><td>$tmt</td>
<td>$tmf</td><td>$tma</td><td>$tmpts</td>
<td>$tmpct</td>
<td>$CISwins</td><td>$CISlosses</td><td>$CISties</td>
<td>$OAwins</td><td>$OAlosses</td><td>$OAties</td>
</tr>";
}



##================OUAMW=======================

print STANHTML "
<tr><th style=text-align:left>O MidWest</th><th>W </th><th>L </th><th>T </th><th>  F  </th><th>   A </th><th>  P </th><th>Pct </th><th>W </th><th>L </th><th>T </th><th>W </th><th>L </th><th>T </th></tr>";

open (STANOUAMW, "<hockstanouamw.txt");

while (<STANOUAMW>) { 
	($tm,$tmconf,$tmgp,$tmw,$tml,$tmt,$tmf,$tma,$tmm,$tmpts,$tmpct,$pfg,$pag,$pmg,$CISwins,$CISlosses,$CISties,$OAwins,$OAlosses,$OAties) = split(':',$_);	

$tmpct = sprintf("%.3f", $tmpct);   ## converts to 3 places
$tmpct =~ s/^0/ /g;                 ## replace Leading Zeros

print STANHTML "
<tr><td style=text-align:left>$tm</td>
<td>$tmw</td><td>$tml</td><td>$tmt</td>
<td>$tmf</td><td>$tma</td><td>$tmpts</td>
<td>$tmpct</td>
<td>$CISwins</td><td>$CISlosses</td><td>$CISties</td>
<td>$OAwins</td><td>$OAlosses</td><td>$OAties</td>
</tr>";
}


##================OUAFW=======================

print STANHTML "
<tr><th style=text-align:left>O FarWest</th><th>W </th><th>L </th><th>T </th><th>  F  </th><th>   A </th><th>  P </th><th>Pct </th><th>W </th><th>L </th><th>T </th><th>W </th><th>L </th><th>T </th></tr>";

open (STANOUAFW, "<hockstanouafw.txt");

while (<STANOUAFW>) { 
	($tm,$tmconf,$tmgp,$tmw,$tml,$tmt,$tmf,$tma,$tmm,$tmpts,$tmpct,$pfg,$pag,$pmg,$CISwins,$CISlosses,$CISties,$OAwins,$OAlosses,$OAties) = split(':',$_);	

$tmpct = sprintf("%.3f", $tmpct);   ## converts to 3 places
$tmpct =~ s/^0/ /g;                 ## replace Leading Zeros

print STANHTML "
<tr><td style=text-align:left>$tm</td>
<td>$tmw</td><td>$tml</td><td>$tmt</td>
<td>$tmf</td><td>$tma</td><td>$tmpts</td>
<td>$tmpct</td>
<td>$CISwins</td><td>$CISlosses</td><td>$CISties</td>
<td>$OAwins</td><td>$OAlosses</td><td>$OAties</td>
</tr>";
}


##================CWGP=======================

print STANHTML "
<tr><th style=text-align:left>CW Plains</th><th>W </th><th>L </th><th>T </th><th>  F  </th><th>   A </th><th>  P </th><th>Pct </th><th>W </th><th>L </th><th>T </th><th>W </th><th>L </th><th>T </th></tr>";

open (STANCWGP, "<hockstancwgp.txt");

while (<STANCWGP>) { 
	($tm,$tmconf,$tmgp,$tmw,$tml,$tmt,$tmf,$tma,$tmm,$tmpts,$tmpct,$pfg,$pag,$pmg,$CISwins,$CISlosses,$CISties,$OAwins,$OAlosses,$OAties) = split(':',$_);	

$tmpct = sprintf("%.3f", $tmpct);   ## converts to 3 places
$tmpct =~ s/^0/ /g;                 ## replace Leading Zeros

print STANHTML "
<tr><td style=text-align:left>$tm</td>
<td>$tmw</td><td>$tml</td><td>$tmt</td>
<td>$tmf</td><td>$tma</td><td>$tmpts</td>
<td>$tmpct</td>
<td>$CISwins</td><td>$CISlosses</td><td>$CISties</td>
<td>$OAwins</td><td>$OAlosses</td><td>$OAties</td>
</tr>";
}


##================CWW=======================

print STANHTML "
<tr><th style=text-align:left>CW West</th><th>W </th><th>L </th><th>T </th><th>  F  </th><th>   A </th><th>  P </th><th>Pct </th><th>W </th><th>L </th><th>T </th><th>W </th><th>L </th><th>T </th></tr>";

open (STANCWW, "<hockstancww.txt");

while (<STANCWW>) { 
	($tm,$tmconf,$tmgp,$tmw,$tml,$tmt,$tmf,$tma,$tmm,$tmpts,$tmpct,$pfg,$pag,$pmg,$CISwins,$CISlosses,$CISties,$OAwins,$OAlosses,$OAties) = split(':',$_);	

$tmpct = sprintf("%.3f", $tmpct);   ## converts to 3 places
$tmpct =~ s/^0/ /g;                 ## replace Leading Zeros

print STANHTML "
<tr><td style=text-align:left>$tm</td>
<td>$tmw</td><td>$tml</td><td>$tmt</td>
<td>$tmf</td><td>$tma</td><td>$tmpts</td>
<td>$tmpct</td>
<td>$CISwins</td><td>$CISlosses</td><td>$CISties</td>
<td>$OAwins</td><td>$OAlosses</td><td>$OAties</td>
</tr>";
}


print STANHTML "</td></tr></table>";


print STANHTML "OL= Overtime Loss add 1 pt in AUS";
    ### END STANDINGS PAGE ###

##  Tm conf g w l t  f  a    m  p    %    fgp   agp     mgp  
##York:aAUS:8:3:5:0:99:205:-106:6:0.375:12.375:25.625:-13.25
##  1    2  3 4 5 6  7  8    9  10   11    12     13     14

#------------------------------------------------------------------
#------------------------------------------------------------------
    ### PREPARE HIGH SCORING PAGE ###
open (HIGHHTML, ">hockhigh0102.html") || die "Can't open $stanfile $!"; 
print HIGHHTML "";
print HIGHHTML "
<HTML><HEAD><title>Hockey Highest Scoring 2001-02</title>
<STYLE>
td {font: 10pt arial; text-align:right}
th {font: 10pt arial; font-weight=bold; text-align:right}
</STYLE>
</head>
<BODY bgcolor=white LINK=0000ff VLINK=0000ff> <Font Face=Arial Size=-1>
<TABLE border=0  cellspacing=3 cellpadding=0 bgcolor=white>
<TR>
<TD align=center colspan=8>
<B>2001-02 Team Comparisons </B>sorted by:
</td></tr>

<tr><th style=text-align:left>   High Scoring   </th><th>W </th><th>L </th><th>T </th><th>  F  </th><th>   A </th><th>  P </th><th>Fpg <th></tr>";


open (HOCKMDA, "<hockstand.txt") || die "Can't open $stanfile $!";
@mda = <HOCKMDA>; 
@mdasorted = map { $_->[0] }
 sort {
      $b->[12] <=> $a->[12]   
||    $b->[10] <=> $a->[10]
||    $b->[11] <=> $a->[11]
||    $b->[14] <=> $a->[14]
||     $a->[1] cmp $b->[1] 
}
map { [ $_, (split /:/, $_,) ] } 
@mda; 


open (HOCKSTANFILE, ">hockstandtemp.txt") || die "Can't open $stanfile $!";
print HOCKSTANFILE @mdasorted;
open (HOCKSTANFILE, "<hockstandtemp.txt") || die "Can't open $stanfile $!";
while (<HOCKSTANFILE>) { 
	($tm,$tmconf,$tmgp,$tmw,$tml,$tmt,$tmf,$tma,$tmm,$tmpts,$tmpct,$pfg,$pag,$pmg) = split(':',$_);	

$pfg = sprintf("%.1f", $pfg);    ## converts to 1 place



print HIGHHTML "
<tr><td style=text-align:left>$tm     </td><td>$tmw</td><td>$tml</td><td>$tmt</td><td>$tmf</td><td>$tma</td><td> $tmpts</td><td> $pfg<td></tr>";
}

print HIGHHTML "</td></tr></table>";
    ### END HIGH SCORING PAGE ###
#------------------------------------------------------------------
#------------------------------------------------------------------
    ### PREPARE LEAST SCORED ON PAGE ###
print LEASTHTML "";
open (LEASTHTML, ">hockleast0102.html") || die "Can't open $stanfile $!"; 
print LEASTHTML "";
print LEASTHTML "
<HTML><HEAD><title>Hockey Least Scored On 2001-02</title>
<STYLE>
td {font: 10pt arial; text-align:right}
th {font: 10pt arial; font-weight=bold; text-align:right}
</STYLE>
</head>
<BODY bgcolor=white LINK=0000ff VLINK=0000ff> <Font Face=Arial Size=-1>
<TABLE border=0  cellspacing=3 cellpadding=0 bgcolor=white>
<TR>
<TD align=center colspan=8>
<B>2001-02 Team Comparisons</B> sorted by:
</td></tr>   

<tr><th style=text-align:left>  Least Against   </th><th>W </th><th>L </th><th>T </th><th>  F  </th><th>   A </th><th>  P </th><th>Apg <th></tr>";


open (HOCKMDA, "<hockstand.txt") || die "Can't open $stanfile $!";
@mda = <HOCKMDA>; 
@mdasorted = map { $_->[0] }
 sort {
      $a->[13] <=> $b->[13]   
||    $b->[10] <=> $a->[10]
||    $b->[11] <=> $a->[11]
||    $b->[14] <=> $a->[14]
||     $a->[1] cmp $b->[1] 
}
map { [ $_, (split /:/, $_,) ] } 
@mda; 


open (HOCKSTANFILE, ">hockstandtemp.txt") || die "Can't open $stanfile $!";
print HOCKSTANFILE @mdasorted;
open (HOCKSTANFILE, "<hockstandtemp.txt") || die "Can't open $stanfile $!";
while (<HOCKSTANFILE>) { 
	($tm,$tmconf,$tmgp,$tmw,$tml,$tmt,$tmf,$tma,$tmm,$tmpts,$tmpct,$pfg,$pag,$pmg) = split(':',$_);	

$pag = sprintf("%.1f", $pag);    ## converts to 1 place


print LEASTHTML "
<tr><td style=text-align:left>$tm     </td><td>$tmw</td><td>$tml</td><td>$tmt</td><td>$tmf</td><td>$tma</td><td> $tmpts</td><td> $pag<td></tr>";
}

print LEASTHTML "</td></tr></table>";
    ### END LEAST SCORED ON PAGE ###
#------------------------------------------------------------------
#------------------------------------------------------------------
    ### PREPARE MARGIN PAGE ###
print LEASTHTML "";
open (MARGHTML, ">hockmargin0102.html") || die "Can't open $stanfile $!"; 
print MARGHTML "";
print MARGHTML "
<HTML><HEAD><title>Hockey Least Scored On 2001-02</title>
<STYLE>
td {font: 10pt arial; text-align:right}
th {font: 10pt arial; font-weight=bold; text-align:right}
</STYLE>
</head>
<BODY bgcolor=white LINK=0000ff VLINK=0000ff> <Font Face=Arial Size=-1>
<TABLE border=0  cellspacing=3 cellpadding=0 bgcolor=white>
<TR>
<TD align=center colspan=8>
<B>2001-02 Team Comparisons sorted by:</B>
</td></tr>

<tr><th style=text-align:left>  WL Margin   </th><th>W </th><th>L </th><th>T </th><th>  F  </th><th>   A </th><th>  P </th><th>Mpg <th></tr>";


open (HOCKMDA, "<hockstand.txt") || die "Can't open $stanfile $!";
@mda = <HOCKMDA>; 
@mdasorted = map { $_->[0] }
 sort {
      $b->[14] <=> $a->[14]   
||    $b->[10] <=> $a->[10]
||    $b->[11] <=> $a->[11]
||     $a->[1] cmp $b->[1] 
}
map { [ $_, (split /:/, $_,) ] } 
@mda; 


open (HOCKSTANFILE, ">hockstandtemp.txt") || die "Can't open $stanfile $!";
print HOCKSTANFILE @mdasorted;
open (HOCKSTANFILE, "<hockstandtemp.txt") || die "Can't open $stanfile $!";
while (<HOCKSTANFILE>) { 
	($tm,$tmconf,$tmgp,$tmw,$tml,$tmt,$tmf,$tma,$tmm,$tmpts,$tmpct,$pfg,$pag,$pmg) = split(':',$_);	

$pmg = sprintf("%.1f", $pmg);    ## converts to 1 place


print MARGHTML "
<tr><td style=text-align:left>$tm     </td><td>$tmw</td><td>$tml</td><td>$tmt</td><td>$tmf</td><td>$tma</td><td> $tmpts</td><td> $pmg<td></tr>";
}

print MARGHTML "</td></tr></table>";
    ### END MARGIN PAGE ###

#------------------------------------------------------------------
#------------------------------------------------------------------
    ### PREPARE WL PERCENT PAGE ###
open (PCTHTML, ">hockpercent0102.html") || die "Can't open $stanfile $!"; 
print PCTHTML "";
print PCTHTML "
<HTML><HEAD><title>Hockey Win Loss Percent 2001-02</title>
<STYLE>
td {font: 10pt arial; text-align:right}
th {font: 10pt arial; font-weight=bold; text-align:right}
</STYLE>
</head>
<BODY bgcolor=white LINK=0000ff VLINK=0000ff> <Font Face=Arial Size=-1>
<TABLE border=0  cellspacing=3 cellpadding=0 bgcolor=white>
<TR>
<TD align=center colspan=8>
<B>2001-02 Team Comparisons</B> sorted by:
</td></tr>

<tr><th style=text-align:left> WL Percent   </th><th>W </th><th>L </th><th>T </th><th>  F  </th><th>   A </th><th>  P </th><th>Pct <th></tr>";


open (HOCKMDA, "<hockstand.txt") || die "Can't open $stanfile $!";
@mda = <HOCKMDA>; 
@mdasorted = map { $_->[0] }
 sort {
      $b->[11] <=> $a->[11]   
||    $b->[10] <=> $a->[10]
||    $b->[14] <=> $a->[14]
||     $a->[1] cmp $b->[1] 
}
map { [ $_, (split /:/, $_,) ] } 
@mda; 


open (HOCKSTANFILE, ">hockstandtemp.txt") || die "Can't open $stanfile $!";
print HOCKSTANFILE @mdasorted;
open (HOCKSTANFILE, "<hockstandtemp.txt") || die "Can't open $stanfile $!";
while (<HOCKSTANFILE>) { 
	($tm,$tmconf,$tmgp,$tmw,$tml,$tmt,$tmf,$tma,$tmm,$tmpts,$tmpct,$pfg,$pag,$pmg) = split(':',$_);	

$tmpct = sprintf("%.3f", $tmpct);   ## converts to 3 places
$tmpct =~ s/^0/ /g;                 ## replace Leading Zeros

print PCTHTML "
<tr><td style=text-align:left>$tm     </td><td>$tmw</td><td>$tml</td><td>$tmt</td><td>$tmf</td><td>$tma</td><td> $tmpts</td><td> $tmpct<td></tr>";
}

print PCTHTML "</td></tr></table>";
    ### END WL PERCENT PAGE ###
#------------------------------------------------------------------
#------------------------------------------------------------------



