#!/usr/local/bin/perl unless ($ARGV[0]) { die "USAGE: ./update_stats \n"; } $hitterSalaryPercent = $ARGV[0]; chomp $hittingSalaryPercent; print STDERR "HITTING SALARY PERCENT = ($hitterSalaryPercent)\n"; @owners = qw/Tom Steve Pete Ted Ivan Mark Marc Claude Chris Lloyd/; @colors = qw/#0099FF #FF9900 #99CCCC #CC9999 #FFFF99 #FF9999 #99CC66 #FFFFFF #66FF99 #CCFF99/; @position = qw/P C 1B 2B 3B SS OF OF OF/; $totalPitchers = 90; open (OUTP, ">mikita.html"); print OUTP ""; print OUTP "Mikita Offseason Valuations"; print OUTP "\n"; print OUTP "\n"; if ($hittingSalaryPercent eq "r") { print OUTP "Values based on Baseball HQ's R\$ values

"; } else { print OUTP "Values based on $hitterSalaryPercent% of salary to offense

"; } open (HITTING, "Batting_NL_P.csv") || die "Couldn't find Batting_NL_P.csv\n"; while () { next if (/Lastname,Firstname/); next if (/Baseball HQ/); next if (/^\s*$/); chomp; (@temp) = split/,/; $name = "$temp[0], $temp[1]"; $name =~ s/"//g; $proj{$name}{pos} = $temp[4]; $proj{$name}{team} = $temp[5]; $proj{$name}{rel} = $temp[6]; $proj{$name}{ab} = $temp[8]; $proj{$name}{run} = $temp[9]; $proj{$name}{hhit} = $temp[10]; $proj{$name}{hr} = $temp[13]; $proj{$name}{rbi} = $temp[14]; $proj{$name}{hbb} = $temp[15]; $proj{$name}{sb} = $temp[17]; $proj{$name}{obp} = $temp[20]; $proj{$name}{val_r} = $temp[23]; $proj{$name}{val_5} = $temp[24]; $proj{$name}{bpv} = $temp[34]; if ($proj{$name}{val_r} == 0) { $proj{$name}{val_r} = 0; } if ($proj{$name}{val_5} == 0) { $proj{$name}{val_5} = 0; } } close (HITTING); open (HITTING, "Batting_AL_P.csv") || die "Couldn't find Batting_AL_P.csv\n"; while () { next if (/Lastname,Firstname/); next if (/Baseball HQ/); next if (/^\s*$/); chomp; (@temp) = split /,/; $name = "$temp[0], $temp[1]"; $name =~ s/"//g; if ($proj{$name}) { print "Duplicate $name!\n"; } $proj{$name}{invalid} = 1; $proj{$name}{team} = $temp[5]; } close (HITTING); open (PITCHING, "Pitching_AL_P.csv") || die "Couldn't find Pitching_AL_P.csv\n"; while () { next if (/Lastname,Firstname/); next if (/Baseball HQ/); next if (/^\s*$/); chomp; (@temp) = split/,/; $name = "$temp[0], $temp[1]"; $name =~ s/"//g; if ($proj{$name}) { print "Duplicate $name!\n"; } $proj{$name}{team} = $temp[4]; $proj{$name}{rel} = $temp[5]; $proj{$name}{win} = $temp[7]; $proj{$name}{save} = $temp[10]; $proj{$name}{ip} = $temp[13]; $proj{$name}{phit} = $temp[14]; $proj{$name}{er} = $temp[15]; $proj{$name}{pbb} = $temp[17]; $proj{$name}{k} = $temp[18]; $proj{$name}{era} = $temp[19]; $proj{$name}{whip} = $temp[20]; $proj{$name}{val_r} = $temp[21]; $proj{$name}{val_5} = $temp[22]; $proj{$name}{bpv} = $temp[33]; $proj{$name}{pos} = 1; if ($proj{$name}{val_r} == 0) { $proj{$name}{val_r} = 0; } if ($proj{$name}{val_5} == 0) { $proj{$name}{val_5} = 0; } } close (PITCHING); open (PITCHING, "Pitching_NL_P.csv") || die "Couldn't find Pitching_NL_p.csv\n"; while () { next if (/Lastname,Firstname/); next if (/Baseball HQ/); next if (/^\s*$/); chomp; (@temp) = split /,/; $name = "$temp[0], $temp[1]"; $name =~ s/"//g; if ($proj{$name}) { print "Duplicate $name!\n"; } $proj{$name}{invalid} = 1; $proj{$name}{team} = $temp[4]; } close (PITCHING); ############################################################################## # Calculate League Average ER, IP, (ERA), Walks, Hits, (WHIP) ############################################################################## @unsorted = (); @sorted = (); $i = 0; foreach $name (keys %proj) { next unless ($proj{$name}{pos} =~ /1/); next if ($proj{$name}{invalid}); @unsorted[$i++] = $name; } @sorted = sort { $proj{$b}{val_r} <=> $proj{$a}{val_r} } @unsorted; for ($i = 0; $i < $totalPitchers; $i++) { $totalIP += $proj{$sorted[$i]}{ip}; $totalER += $proj{$sorted[$i]}{er}; $totalBB += $proj{$sorted[$i]}{pbb}; $totalHit += $proj{$sorted[$i]}{phit}; } $avgERA = ($totalER * 9) / $totalIP; $avgWHIP = ($totalHit + $totalBB) / $totalIP; $avgIP = $totalIP / $totalPitchers; $avgER = $totalER / $totalPitchers; $avgBB = $totalBB / $totalPitchers; $avgHit = $totalHit / $totalPitchers; foreach $name (@sorted) { $proj{$name}{tera} = (((($avgER*8)+$proj{$name}{er})*9)/(($avgIP*8)+$proj{$name}{ip})); $proj{$name}{nera} = $avgERA - $proj{$name}{tera}; $proj{$name}{twhip} = (((($avgHit+$avgBB)*8)+$proj{$name}{hit}+$proj{$name}{bb}) / (($avgIP*8)+$proj{$name}{ip})); $proj{$name}{nwhip} = $avgWHIP - $proj{$name}{twhip}; # printf "%25s tera=%1.4f nera=%1.4f twhip=%1.4f nwhip=%1.4f\n", $name, $proj{$name}{tera}, $proj{$name}{nera}, $proj{$name}{twhip}, $proj{$name}{nwhip}; } ############################################################################### unless ($hittingSalaryPercent eq "r") { `./pvm_calculation $hitterSalaryPercent`; open (PVM, "pvm_values") || die "Couldn't open pvm_values"; while () { next if (/^###/); next if (/^\s*$/); chomp; @temp = split /,/; $name = "$temp[0], $temp[1]"; $name =~ s/"//g; $proj{$name}{val_p} = $temp[2]; if ($proj{$name}{pos} =~ /1/) { $proj{$name}{val_c}{win} = $temp[3]; $proj{$name}{val_c}{save} = $temp[4]; $proj{$name}{val_c}{era} = $temp[5]; $proj{$name}{val_c}{whip} = $temp[6]; $proj{$name}{val_c}{k} = $temp[7]; } else { $proj{$name}{val_c}{hr} = $temp[3]; $proj{$name}{val_c}{rbi} = $temp[4]; $proj{$name}{val_c}{run} = $temp[5]; $proj{$name}{val_c}{sb} = $temp[6]; $proj{$name}{val_c}{obp} = $temp[7]; } } close (PVM); } open (ROSTERS, "Mikita_Rosters_Offseason_Keepers.csv") || die "Couldn't find Mikita_Rosters_Offseason_Keepers.csv\n"; while () { next if (/Last,First/); next if (/^\s*$/); chomp; $i++; (@temp) = split/,/; $name = "$temp[0], $temp[1]"; $name =~ s/"//g; $roster{$name}{contract} = $temp[2]; $roster{$name}{salary} = $temp[3]; $roster{$name}{owner} = $temp[4]; $roster{$name}{keep} = 1 if ($temp[5] eq "keep"); unless ($proj{$name}) { $roster{$name}{dnf} = 1; } $proj{$name}{owner} = $temp[4]; if ($roster{$name}{dnf}) { $proj{$name}{val_p} = -100; $proj{$name}{val_r} = -100; } elsif ($proj{$name}{invalid}) { $proj{$name}{val_p} = -200; $proj{$name}{val_r} = -200; } else { if ($hittingSalaryPercent eq "r") { $roster{$name}{profit} = $proj{$name}{val_r} - $roster{$name}{salary}; } else { $roster{$name}{profit} = $proj{$name}{val_p} - $roster{$name}{salary}; } } $aucName = "$temp[0],$temp[1]"; $aucName =~ s/"//g; $aucVal = `grep \"$aucName\" 2008_auction_values.csv`; if ($aucVal) { chomp $aucVal; ($roster{$name}{aucVal}) = ($aucVal =~ /,(\d+)/); } else { $roster{$name}{aucVal} = 0; } $roster{$name}{aucPro} = $roster{$name}{aucVal} - $roster{$name}{salary}; } close (ROSTERS); ######################################################################################### # print tables of each team, with salaries, profit, etc. ######################################################################################### $i = 0; foreach $temp (@owners) { @thisteam = (); $count = 0; $thisowner = $temp; $teamstats{$thisowner}{left} = 260; $teamstats{$thisowner}{kprcount} = 0; # team keeper count foreach $name (keys %roster) { next unless ($temp eq $roster{$name}{owner}); $thisteam[$count++] = $name; } if ($hittingSalaryPercent eq "r") { @sorted = sort { $proj{$b}{val_r} <=> $proj{$a}{val_r} } @thisteam; } else { @sorted = sort { $proj{$b}{val_p} <=> $proj{$a}{val_p} } @thisteam; } print OUTP ""; print OUTP "Tom|Steve|Pete|"; print OUTP "Ted|Ivan|Mark|"; print OUTP "Marc|Claude|"; print OUTP "Chris|Lloyd|"; print OUTP "Team Ranks|Team Stats|"; print OUTP "Top Remaining"; print OUTP "\n"; print OUTP "
Owner: $temp\n"; print OUTP "
PlayerContractSalary"; print OUTP "ValueProfitAucValAucProKeeper?"; print OUTP "PosHR/WRBI/SvR/KSB/ERAOBP/WHIP"; for ($thisp = 0; $thisp < $count; $thisp++) { $name = $sorted[$thisp]; $keeper = 0; $havetokeep = 0; if ($proj{$name}{invalid}) { print OUTP "
$name$roster{$name}{contract}"; print OUTP "INVALID\n"; } elsif ($roster{$name}{dnf}) { print OUTP "
$name$roster{$name}{contract}"; print OUTP "Did Not Find\n"; } else { if ($hittingSalaryPercent eq "r") { $value = $proj{$name}{val_r}; } else { $value = $proj{$name}{val_p}; } print OUTP "
$name"; print OUTP "$roster{$name}{contract}"; print OUTP "$roster{$name}{salary}"; print OUTP "$value"; print OUTP "$roster{$name}{profit}"; if (($roster{$name}{aucVal} < $value) && ($roster{$name}{aucPro} > 0)) { print OUTP "$roster{$name}{aucVal}"; } else { print OUTP "$roster{$name}{aucVal}"; } print OUTP "$roster{$name}{aucPro}"; $keeper = 1 if ($roster{$name}{keep}); if ($roster{$name}{contract} =~ /R\d+/) { $roster{$name}{keep} = 1; $color = "#66CCFF"; $ktxt = "reserve"; if ($proj{$name}{val_p} > 5) { if ($proj{$name}{pos} == 1) { $teamstats{$thisowner}{win} += $proj{$name}{win}; $teamstats{$thisowner}{save} += $proj{$name}{save}; $teamstats{$thisowner}{k} += $proj{$name}{k}; $teamstats{$thisowner}{ip} += $proj{$name}{ip}; $teamstats{$thisowner}{er} += $proj{$name}{er}; $teamstats{$thisowner}{phit} += $proj{$name}{phit}; $teamstats{$thisowner}{pbb} += $proj{$name}{pbb} } else { $teamstats{$thisowner}{hr} += $proj{$name}{hr}; $teamstats{$thisowner}{sb} += $proj{$name}{sb}; $teamstats{$thisowner}{rbi} += $proj{$name}{rbi}; $teamstats{$thisowner}{run} += $proj{$name}{run}; $teamstats{$thisowner}{hhit} += $proj{$name}{hhit}; $teamstats{$thisowner}{hbb} += $proj{$name}{hbb}; $teamstats{$thisowner}{ab} += $proj{$name}{ab}; } } } elsif ($keeper) { $teamstats{$thisowner}{kprcount}++; $color = "#00CC00"; $ktxt = "yes"; if ($hittingSalaryPercent eq "r") { $teamstats{$thisowner}{value} += $proj{$name}{val_r}; } else { $teamstats{$thisowner}{value} += $proj{$name}{val_p}; } $teamstats{$thisowner}{salary} += $roster{$name}{salary}; $teamstats{$thisowner}{left} -= $roster{$name}{salary}; $teamstats{$thisowner}{profit} += $roster{$name}{profit}; $teamstats{$thisowner}{aucVal} += $roster{$name}{aucVal}; $teamstats{$thisowner}{aucPro} += $roster{$name}{aucPro}; if ($proj{$name}{pos} == 1) { $teamstats{$thisowner}{psalary} += $roster{$name}{salary}; $teamstats{$thisowner}{win} += $proj{$name}{win}; $teamstats{$thisowner}{save} += $proj{$name}{save}; $teamstats{$thisowner}{k} += $proj{$name}{k}; $teamstats{$thisowner}{ip} += $proj{$name}{ip}; $teamstats{$thisowner}{er} += $proj{$name}{er}; $teamstats{$thisowner}{phit} += $proj{$name}{phit}; $teamstats{$thisowner}{pbb} += $proj{$name}{pbb} } else { $teamstats{$thisowner}{hsalary} += $roster{$name}{salary}; $teamstats{$thisowner}{hr} += $proj{$name}{hr}; $teamstats{$thisowner}{sb} += $proj{$name}{sb}; $teamstats{$thisowner}{rbi} += $proj{$name}{rbi}; $teamstats{$thisowner}{run} += $proj{$name}{run}; $teamstats{$thisowner}{hhit} += $proj{$name}{hhit}; $teamstats{$thisowner}{hbb} += $proj{$name}{hbb}; $teamstats{$thisowner}{ab} += $proj{$name}{ab}; } } else { $color = red; $ktxt = "no"; } printf OUTP "$ktxt\n"; } unless ($proj{$name}{invalid} || $roster{$name}{dnf}) { if ($proj{$name}{pos} =~ /1/) { print OUTP "$proj{$name}{pos}"; print OUTP "$proj{$name}{win} (\$$proj{$name}{val_c}{win})"; print OUTP "$proj{$name}{save} (\$$proj{$name}{val_c}{save})"; print OUTP "$proj{$name}{k} (\$$proj{$name}{val_c}{k})"; printf OUTP "%1.2f (\$$proj{$name}{val_c}{era})", $proj{$name}{era}; printf OUTP "%1.2f (\$$proj{$name}{val_c}{whip})", $proj{$name}{whip}; } else { print OUTP "$proj{$name}{pos}"; print OUTP "$proj{$name}{hr} (\$$proj{$name}{val_c}{hr})"; print OUTP "$proj{$name}{rbi} (\$$proj{$name}{val_c}{rbi})"; print OUTP "$proj{$name}{run} (\$$proj{$name}{val_c}{run})"; print OUTP "$proj{$name}{sb} (\$$proj{$name}{val_c}{sb})"; print OUTP "$proj{$name}{obp} (\$$proj{$name}{val_c}{obp})"; } } } print OUTP "
"; print OUTP "Keepers=$teamstats{$thisowner}{kprcount}, Value=$teamstats{$thisowner}{value},"; print OUTP " Cost=$teamstats{$thisowner}{salary}, Profit=$teamstats{$thisowner}{profit},"; print OUTP " Avg Auction Val=$teamstats{$thisowner}{aucVal}, Auction Profit=$teamstats{$thisowner}{aucPro}, "; print OUTP " Left=$teamstats{$thisowner}{left}\n"; print OUTP "


\n"; $i++; } foreach $name (keys %teamstats) { $teamstats{$name}{obp} = ($teamstats{$name}{hhit} + $teamstats{$name}{hbb}) / ($teamstats{$name}{ab} + $teamstats{$name}{hbb}); $teamstats{$name}{whip} = ($teamstats{$name}{phit} + $teamstats{$name}{pbb}) / $teamstats{$name}{ip}; $teamstats{$name}{era} = ($teamstats{$name}{er} * 9) / $teamstats{$name}{ip}; } ######################################################################################### # Assign point values based on team stats, print table of rankings ######################################################################################### $i = 0; @unsorted = (); @sorted = (); @statlist = (); foreach $name (keys %teamstats) { $unsorted[$i++] = $name; } @statlist = qw/hr rbi run sb obp win save k era whip/; foreach $stat (@statlist) { $catpoints = 10; if (($stat eq "era") || ($stat eq "whip")) { @sorted = sort { $teamstats{$a}{$stat} <=> $teamstats{$b}{$stat} } @unsorted; } else { @sorted = sort { $teamstats{$b}{$stat} <=> $teamstats{$a}{$stat} } @unsorted; } for ($i = 0; $i < int(@sorted); $i++) { $points{$sorted[$i]}{$stat} = $catpoints--; $points{$sorted[$i]}{total} += $points{$sorted[$i]}{$stat}; if (($stat eq "hr") || ($stat eq "rbi") || ($stat eq "run") || ($stat eq "sb") || ($stat eq "obp")) { $points{$sorted[$i]}{offense} += $points{$sorted[$i]}{$stat}; } else { $points{$sorted[$i]}{pitching} += $points{$sorted[$i]}{$stat}; } } } print OUTP ""; print OUTP "Tom|Steve|Pete|"; print OUTP "Ted|Ivan|Mark|"; print OUTP "Marc|Claude|"; print OUTP "Chris|Lloyd|"; print OUTP "Team Ranks|Team Stats|"; print OUTP "Top Remaining"; print OUTP ""; print OUTP "
Team Point Rankings Based on Keeper Stats"; print OUTP "
RankOwnerHRRBIRunSBOBP\n"; print OUTP "WinSaveKERAWHIP"; print OUTP "OffensePitchingTotal"; @sorted = (); @sorted = sort { $points{$b}{total} <=> $points{$a}{total} } @unsorted; for ($i = 0; $i < int(@sorted); $i++) { printf OUTP "
%2d$sorted[$i]", $i+1; print OUTP "$points{$sorted[$i]}{hr}"; print OUTP "$points{$sorted[$i]}{rbi}"; print OUTP "$points{$sorted[$i]}{run}"; print OUTP "$points{$sorted[$i]}{sb}"; print OUTP "$points{$sorted[$i]}{obp}"; print OUTP "$points{$sorted[$i]}{win}"; print OUTP "$points{$sorted[$i]}{save}"; print OUTP "$points{$sorted[$i]}{k}"; print OUTP "$points{$sorted[$i]}{era}"; print OUTP "$points{$sorted[$i]}{whip}"; print OUTP "$points{$sorted[$i]}{offense}"; print OUTP "$points{$sorted[$i]}{pitching}"; print OUTP "$points{$sorted[$i]}{total}"; } print OUTP "


"; ######################################################################################### # Print out table of each team's keeper stats ######################################################################################### $totalValue = 0; $totalSalary = 0; $totalLeft = 0; print OUTP ""; print OUTP "Tom|Steve|Pete|"; print OUTP "Ted|Ivan|Mark|"; print OUTP "Marc|Claude|"; print OUTP "Chris|Lloyd|"; print OUTP "Team Ranks|Team Stats|"; print OUTP "Top Remaining"; print OUTP ""; print OUTP "
Team Keeper Stat Totals"; print OUTP "
RankOwner# Keepers"; print OUTP "ValueSalaryProfit\$LeftAucVal"; print OUTP "HRsRBIsRunsSBsOBP"; print OUTP "WinsSavesKsERAWHIP"; for ($i = 0; $i < int(@sorted); $i++) { printf OUTP "
%2d$sorted[$i]", $i+1; print OUTP "$teamstats{$sorted[$i]}{kprcount}"; print OUTP "$teamstats{$sorted[$i]}{value}"; $totalValue += $teamstats{$sorted[$i]}{value}; print OUTP "$teamstats{$sorted[$i]}{salary}"; $totalSalary += $teamstats{$sorted[$i]}{salary}; print OUTP "$teamstats{$sorted[$i]}{profit}"; $totalProfit += $teamstats{$sorted[$i]}{profit}; print OUTP "$teamstats{$sorted[$i]}{left}"; $totalLeft += $teamstats{$sorted[$i]}{left}; print OUTP "$teamstats{$sorted[$i]}{aucVal}"; $totalAucVal += $teamstats{$sorted[$i]}{aucVal}; print OUTP "$teamstats{$sorted[$i]}{hr}"; print OUTP "$teamstats{$sorted[$i]}{rbi}"; print OUTP "$teamstats{$sorted[$i]}{run}"; print OUTP "$teamstats{$sorted[$i]}{sb}"; printf OUTP "%0.3f", $teamstats{$sorted[$i]}{obp}; if ($teamstats{$sorted[$i]}{win}) { printf OUTP "$teamstats{$sorted[$i]}{win}"; } else { print OUTP "0"; } if ($teamstats{$sorted[$i]}{save}) { printf OUTP "$teamstats{$sorted[$i]}{save}"; } else { print OUTP "0"; } if ($teamstats{$sorted[$i]}{k}) { printf OUTP "$teamstats{$sorted[$i]}{k}"; } else { print OUTP "0"; } printf OUTP "%1.2f", $teamstats{$sorted[$i]}{era}; printf OUTP "%1.2f", $teamstats{$sorted[$i]}{whip}; } print OUTP "
Totals$totalValue$totalSalary"; print OUTP "$totalProfit$totalLeft$totalAucVal"; $valueLeft = 2600 - $totalValue; # gives value left for auction $inflationRate = $totalLeft / $valueLeft; # multiplier printf OUTP "Inflation rate = %1.2f", $inflationRate; print OUTP "
"; print OUTP "


"; ######################################################################################### # Print out table of top value players still available ######################################################################################### print OUTP ""; print OUTP "Tom|Steve|Pete|"; print OUTP "Ted|Ivan|Mark|"; print OUTP "Marc|Claude|"; print OUTP "Chris|Lloyd|"; print OUTP "Team Ranks|Team Stats|"; print OUTP "Top Remaining"; print OUTP "
"; @unsorted = (); @sorted = (); $i = 0; foreach $name (keys %proj) { $unsorted[$i++] = $name; } @sorted = sort { $proj{$b}{val_p} <=> $proj{$a}{val_p} } @unsorted; print OUTP ""; print OUTP "
Top Remaining Value Players"; for ($i = 0; $i < int(@sorted); $i++) { last if ($proj{$sorted[$i]}{val_p} < 10); next if ($roster{$sorted[$i]}{keep}); next if ($proj{$sorted[$i]}{invalid} == 1); print OUTP "
$sorted[$i]\$$proj{$sorted[$i]}{val_p}"; } print OUTP "
"; ######################################################################################### # Print out tables of top stat getters in each stat ######################################################################################### $i = 0; foreach $name (keys %proj) { $unsorted[$i++] = $name; } print OUTP "
"; print OUTP ""; @statlist = qw/hr rbi run sb obp win save k era whip/; foreach $stat (@statlist) { @sorted = (); $thiscount = 0; if ($stat eq "win") { print OUTP ""; } print OUTP "
"; print OUTP "
Top remaining $stat players"; @sorted = sort { $proj{$b}{val_c}{$stat} <=> $proj{$a}{val_c}{$stat} } @unsorted; for ($i = 0; $i < int(@sorted); $i++) { next unless ($proj{$sorted[$i]}{val_c}{$stat}); next if ($roster{$sorted[$i]}{keep}); next if ($proj{$sorted[$i]}{invalid} == 1); if (($stat eq "era") || ($stat eq "whip")) { printf OUTP "
$sorted[$i]%1.2f", $proj{$sorted[$i]}{$stat}; } else { print OUTP "
$sorted[$i]$proj{$sorted[$i]}{$stat}"; } $thiscount++; last if ($thiscount > 9); } print OUTP "
"; } print OUTP "

"; ######################################################################################### # Print out tables of top value players at each position ######################################################################################### @sorted = (); if ($hittingSalaryPercent eq "r") { @sorted = sort { $proj{$b}{val_r} <=> $proj{$a}{val_r} } @unsorted; } else { @sorted = sort { $proj{$b}{val_p} <=> $proj{$a}{val_p} } @unsorted; } for ($thispos = 1; $thispos < 8; $thispos++) { $count = 0; print OUTP "
"; print OUTP "Tom|Steve|Pete|"; print OUTP "Ted|Ivan|Mark|"; print OUTP "Marc|Claude|"; print OUTP "Chris|Lloyd|"; print OUTP "Team Ranks|Team Stats|"; print OUTP "Top Remaining"; print OUTP ""; print OUTP "
Top Remaining Players at "; if ($thispos == 1) { print OUTP "Pitcher\n"; } elsif ($thispos == 2) { print OUTP "Catcher\n"; } elsif ($thispos == 3) { print OUTP "First Base\n"; } elsif ($thispos == 4) { print OUTP "Second Base\n"; } elsif ($thispos == 5) { print OUTP "Third Base\n"; } elsif ($thispos == 6) { print OUTP "Shortstop\n"; } elsif ($thispos == 7) { print OUTP "Outfield\n"; } print OUTP "
PlayerValue\n"; if ($thispos == 1) { print OUTP "WinsSavesKsERAWHIP"; } else { print OUTP "HRsRunsRBIsSBsOBP"; } for ($i = 0; $i < int(@sorted); $i++) { if ($thispos < 7) { next unless ($proj{$sorted[$i]}{pos} =~ /$thispos/); } else { next unless ($proj{$sorted[$i]}{pos} =~ /[789]/); } next if ($roster{$sorted[$i]}{keep}); $count++; print OUTP "
$sorted[$i]$proj{$sorted[$i]}{val_p}\n"; if ($thispos == 1) { print OUTP "$proj{$sorted[$i]}{win} (\$$proj{$sorted[$i]}{val_c}{win})"; print OUTP "$proj{$sorted[$i]}{save} (\$$proj{$sorted[$i]}{val_c}{save})"; print OUTP "$proj{$sorted[$i]}{k} (\$$proj{$sorted[$i]}{val_c}{k})"; printf OUTP "%1.2f (\$$proj{$sorted[$i]}{val_c}{era})", $proj{$sorted[$i]}{era}; printf OUTP "%1.2f (\$$proj{$sorted[$i]}{val_c}{whip})", $proj{$sorted[$i]}{whip}; } else { print OUTP "$proj{$sorted[$i]}{hr} (\$$proj{$sorted[$i]}{val_c}{hr})"; print OUTP "$proj{$sorted[$i]}{run} (\$$proj{$sorted[$i]}{val_c}{run})"; print OUTP "$proj{$sorted[$i]}{rbi} (\$$proj{$sorted[$i]}{val_c}{rbi})"; print OUTP "$proj{$sorted[$i]}{sb} (\$$proj{$sorted[$i]}{val_c}{sb})"; print OUTP "$proj{$sorted[$i]}{obp} (\$$proj{$sorted[$i]}{val_c}{obp})"; } if ($thispos == 7) { last if ($count > 29); } else { last if ($count > 19); } } print OUTP "

"; } print OUTP "";