# FILE fbscocomb.pl working copy running time 17 sec
#============= CREATE SCORES PAGE ===================
$scofile='FBsco01.txt';
open (SCORES,"<$scofile") || die "Can't open $scorefile $!";
open (SCORESHTML, ">fbscores01.html");
print SCORESHTML "
CIAU football scores 2001
\n
FB Scores 2001";
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='FBsco01.txt';
open (SCORES,"<$scofile") || die "Can't open $scorefile $!";
open (TEAMDATA, ">fbteams01.html");
print TEAMDATA "
";
@TeamName = ("Acadia", "Mt Allison", "Saint Mary's", "StFX",
"Bishop's", "Concordia", "Laval", "McGill",
"Guelph", "Laurier", "McMaster", "Ottawa", "Queen's",
"Toronto", "Waterloo", "Western", "Windsor", "York",
"Alberta", "Calgary", "Regina", "Saskatchewan", "Manitoba",
"UBC",);
foreach $team (@TeamName) {
open (TEAMDATA, ">>fbteams01.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='FBsco01.txt';
open (FBMDA, ">fbstand.txt") || die "Can't open fbstand.txt $!";
print FBMDA "";
@TeamName = ("Acadia", "Mt Allison", "Saint Mary's", "StFX",
"Bishop's", "Concordia", "Laval", "McGill",
"Guelph", "Laurier", "McMaster", "Ottawa", "Queen's",
"Toronto", "Waterloo", "Western", "Windsor", "York",
"Alberta", "Calgary", "Regina", "Saskatchewan", "Manitoba",
"UBC",);
foreach $team (@TeamName) {
open (SCORES,"<$scofile") || die "Can't open $scorefile $!";
open (FBMDA, ">>fbstand.txt") || die "Can't open fbstand.txt $!";
($teamwins, $teamlosses, $pfor, $Against, $WLpct) =0; # initialize counts
$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;
# while reading SCORES (FBsco01.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
}
#=================================================
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|Mt Allison|Saint Mary's|StFX/) {
$conf = "aAU";
}
elsif ($team =~ /Bishop's|Concordia|Laval|McGill/) {
$conf = "bQU";
}
elsif ($team =~ /Guelph|Laurier|McMaster|Ottawa|Queen's|
Toronto|Waterloo|Western|Windsor|York/) {
$conf = "cOU";
}
elsif ($team =~ /Alberta|Calgary|Manitoba|Regina|Saskatchewan|UBC/) {
$conf = "dCW";
}
}
# END calculation of standings variables for Team.
print FBMDA "$team:$conf:$teamgp:$teamwins:$teamlosses:$teamties:$pfor:$Against:$Margin:$Pts:$WLpct:$pfpg:$papg:$mgp\n";
}
close FBMDA;
#====================================================
#### SORTING STANDINGS ###
#====================================================
$stanfile='fbstand.txt';
open (FBMDA, ";
@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, ">fbstand01.html");
print STANHTM "";
open (STANHTML, ">>fbstand01.html");
open (STANAUS, ">fbstanaus.txt");
open (STANQUE, ">fbstanque.txt");
open (STANOUA, ">fbstanoua.txt");
open (STANCW, ">fbstancw.txt");
print STANAUS @mdasorted[0 .. 3]; ##AUS .. begins zero
print STANQUE @mdasorted[4 .. 7]; ##Quebec
print STANOUA @mdasorted[8 .. 17]; ##OUA
print STANCW @mdasorted[18 .. 24]; ##CanWest
##======================================================
print STANHTML "
FB Standings 2001
2001 Football Standings |
";
##======================================================
##================AUS=======================
print STANHTML "
Atlantic | W | L | T | F | A | P | Pct | |
";
open (STANAUS, ") {
($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 STANHTML "
$tm | $tmw | $tml | $tmt | $tmf | $tma | $tmpts | $tmpct | |
";
}
##================QUE=======================
print STANHTML "
Quebec | W | L | T | F | A | P | Pct | |
";
open (STANQUE, ") {
($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 STANHTML "
$tm | $tmw | $tml | $tmt | $tmf | $tma | $tmpts | $tmpct | |
";
}
##================OUA=======================
print STANHTML "
Ontario | W | L | T | F | A | P | Pct | |
";
open (STANOUA, ") {
($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 STANHTML "
$tm | $tmw | $tml | $tmt | $tmf | $tma | $tmpts | $tmpct | |
";
}
##================CW=======================
print STANHTML "
CanWest | W | L | T | F | A | P | Pct | |
";
open (STANCW, ") {
($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 STANHTML "$tm | $tmw | $tml | $tmt | $tmf | $tma | $tmpts | $tmpct |
";
}
print STANHTML "
";
print STANHTML "OL= Overtime Loss add 1 pt in CW";
### 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, ">fbhigh01.html") || die "Can't open $stanfile $!";
print HIGHHTML "";
print HIGHHTML "
FB Highest Scoring 2001
2001 Team Comparisons sorted by:
|
High Scoring | W | L | T | F | A | P | Fpg | |
";
open (FBMDA, ";
@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 (FBSTANFILE, ">fbstandtemp.txt") || die "Can't open $stanfile $!";
print FBSTANFILE @mdasorted;
open (FBSTANFILE, ") {
($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 "
$tm | $tmw | $tml | $tmt | $tmf | $tma | $tmpts | $pfg | |
";
}
print HIGHHTML "
";
### END HIGH SCORING PAGE ###
#------------------------------------------------------------------
#------------------------------------------------------------------
### PREPARE LEAST SCORED ON PAGE ###
print LEASTHTML "";
open (LEASTHTML, ">fbleast01.html") || die "Can't open $stanfile $!";
print LEASTHTML "";
print LEASTHTML "
FB Least Scored On 2001
2001 Team Comparisons sorted by:
|
Least Against | W | L | T | F | A | P | Apg | |
";
open (FBMDA, ";
@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 (FBSTANFILE, ">fbstandtemp.txt") || die "Can't open $stanfile $!";
print FBSTANFILE @mdasorted;
open (FBSTANFILE, ") {
($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 "
$tm | $tmw | $tml | $tmt | $tmf | $tma | $tmpts | $pag | |
";
}
print LEASTHTML "
";
### END LEAST SCORED ON PAGE ###
#------------------------------------------------------------------
#------------------------------------------------------------------
### PREPARE MARGIN PAGE ###
print LEASTHTML "";
open (MARGHTML, ">fbmargin01.html") || die "Can't open $stanfile $!";
print MARGHTML "";
print MARGHTML "
FB Least Scored On 2001
2001 Team Comparisons sorted by:
|
WL Margin | W | L | T | F | A | P | Mpg | |
";
open (FBMDA, ";
@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 (FBSTANFILE, ">fbstandtemp.txt") || die "Can't open $stanfile $!";
print FBSTANFILE @mdasorted;
open (FBSTANFILE, ") {
($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 "
$tm | $tmw | $tml | $tmt | $tmf | $tma | $tmpts | $pmg | |
";
}
print MARGHTML "
";
### END MARGIN PAGE ###
#------------------------------------------------------------------
#------------------------------------------------------------------
### PREPARE WL PERCENT PAGE ###
open (PCTHTML, ">fbpercent01.html") || die "Can't open $stanfile $!";
print PCTHTML "";
print PCTHTML "
FB Least Scored On 2001
2001 Team Comparisons sorted by:
|
WL Percent | W | L | T | F | A | P | Pct | |
";
open (FBMDA, ";
@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 (FBSTANFILE, ">fbstandtemp.txt") || die "Can't open $stanfile $!";
print FBSTANFILE @mdasorted;
open (FBSTANFILE, ") {
($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 "
$tm | $tmw | $tml | $tmt | $tmf | $tma | $tmpts | $tmpct | |
";
}
print PCTHTML "
";
### END WL PERCENT PAGE ###
#------------------------------------------------------------------
#------------------------------------------------------------------