# 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 "CIAU Hockey scores 2001-02 \n Hockey Scores 2001-02"; while () { ($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 "$date\n"; next; } # print date if alone on datafile row if ($Tm1 le " ") { print SCORESHTML "
$date\n"; } #print score lines without dates else { print SCORESHTML "
$Tm1 $Sco1 $Tm2 $Sco2 $GmType $Notes\n"; } } print SCORESHTML ""; #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 "
2001-02 Hockey Scores by Team
Atlantic
AUS
Acadia
Dalhousie
Saint Mary's
Moncton
StFX
St. Thomas
UNB
UPEI
OUA
QIFC
Concordia
McGill
Ottawa
UQTR
Queen's
RMC
Ryerson
Toronto
OUA
OUA
Brock
Guelph
Laurier
York
Lakehead
Waterloo
Western
Windsor
CanWest
CWUAA
Brandon
Manitoba
Regina
Saskatchewan
Alberta
Calgary
Lethbridge
UBC
  "; @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 "

$team\n"; open (SCORES,"<$scofile") || die "Can't open $scorefile $!"; while () { ($Date,$Tm1,$Sco1,$Tm2,$Sco2,$GmType,$Notes) = split(':',$_); if ($Tm1 eq $team || $Tm2 eq $team) { print TEAMDATA "
$Date $Tm1 $Sco1 $Tm2 $Sco2 $GmType $Notes\n"; } } } print TEAMDATA ""; #==================================================== #### 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 () { ($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, "; @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 " HOCKEY Standings 2001-02 "; ##====================================================== ##================AUS======================= print STANHTML " "; open (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 " "; } ##================OUAFE======================= print STANHTML " "; open (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 " "; } ##================OUAME======================= print STANHTML " "; open (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 " "; } ##================OUAMW======================= print STANHTML " "; open (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 " "; } ##================OUAFW======================= print STANHTML " "; open (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 " "; } ##================CWGP======================= print STANHTML " "; open (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 " "; } ##================CWW======================= print STANHTML " "; open (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 " "; } print STANHTML "
2001-02 Hockey Standings
  CONFERENCEAll-CISOverall
Atlantic W L T F A P Pct W L T W L T
$tm $tmw$tml$tmt $tmf$tma$tmpts $tmpct $CISwins$CISlosses$CISties $OAwins$OAlosses$OAties
O FarEast W L T F A P Pct W L T W L T
$tm $tmw$tml$tmt $tmf$tma$tmpts $tmpct $CISwins$CISlosses$CISties $OAwins$OAlosses$OAties
O MidEastW L T F A P Pct W L T W L T
$tm $tmw$tml$tmt $tmf$tma$tmpts $tmpct $CISwins$CISlosses$CISties $OAwins$OAlosses$OAties
O MidWestW L T F A P Pct W L T W L T
$tm $tmw$tml$tmt $tmf$tma$tmpts $tmpct $CISwins$CISlosses$CISties $OAwins$OAlosses$OAties
O FarWestW L T F A P Pct W L T W L T
$tm $tmw$tml$tmt $tmf$tma$tmpts $tmpct $CISwins$CISlosses$CISties $OAwins$OAlosses$OAties
CW PlainsW L T F A P Pct W L T W L T
$tm $tmw$tml$tmt $tmf$tma$tmpts $tmpct $CISwins$CISlosses$CISties $OAwins$OAlosses$OAties
CW WestW L T F A P Pct W L T W L T
$tm $tmw$tml$tmt $tmf$tma$tmpts $tmpct $CISwins$CISlosses$CISties $OAwins$OAlosses$OAties
"; 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 " Hockey Highest Scoring 2001-02 "; open (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, ") { ($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 " "; } print HIGHHTML "
2001-02 Team Comparisons sorted by:
High Scoring W L T F A P Fpg
$tm $tmw$tml$tmt$tmf$tma $tmpts $pfg
"; ### END HIGH SCORING PAGE ### #------------------------------------------------------------------ #------------------------------------------------------------------ ### PREPARE LEAST SCORED ON PAGE ### print LEASTHTML ""; open (LEASTHTML, ">hockleast0102.html") || die "Can't open $stanfile $!"; print LEASTHTML ""; print LEASTHTML " Hockey Least Scored On 2001-02 "; open (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, ") { ($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 " "; } print LEASTHTML "
2001-02 Team Comparisons sorted by:
Least Against W L T F A P Apg
$tm $tmw$tml$tmt$tmf$tma $tmpts $pag
"; ### END LEAST SCORED ON PAGE ### #------------------------------------------------------------------ #------------------------------------------------------------------ ### PREPARE MARGIN PAGE ### print LEASTHTML ""; open (MARGHTML, ">hockmargin0102.html") || die "Can't open $stanfile $!"; print MARGHTML ""; print MARGHTML " Hockey Least Scored On 2001-02 "; open (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, ") { ($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 " "; } print MARGHTML "
2001-02 Team Comparisons sorted by:
WL Margin W L T F A P Mpg
$tm $tmw$tml$tmt$tmf$tma $tmpts $pmg
"; ### END MARGIN PAGE ### #------------------------------------------------------------------ #------------------------------------------------------------------ ### PREPARE WL PERCENT PAGE ### open (PCTHTML, ">hockpercent0102.html") || die "Can't open $stanfile $!"; print PCTHTML ""; print PCTHTML " Hockey Win Loss Percent 2001-02 "; open (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, ") { ($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 " "; } print PCTHTML "
2001-02 Team Comparisons sorted by:
WL Percent W L T F A P Pct
$tm $tmw$tml$tmt$tmf$tma $tmpts $tmpct
"; ### END WL PERCENT PAGE ### #------------------------------------------------------------------ #------------------------------------------------------------------