Sorry, I just thought the text would be too long.
=========================================================================
#! /perl/bin/perl
$Course_Name = "White-Run Golf Club";
$Course_Tee = "White";
$Course_Rate = "70.3";
$Course_Slope = "124";
#Current Course Data:
#@Course_Par = (4,5,4,3,5,4,3,4,4,5,4,3,4,4,4,5,3,4);
#@Course_Yardage =
(375,544,391,158,524,310,176,405,381,536,415,184,370,313,366,504,186,356);
#@Course_Handicap = (13,7,3,17,9,15,11,1,5,10,2,8,6,18,4,12,14,16);
#2000 Course Data:
@Course_Par = (5,4,3,4,4,4,5,3,4,4,5,4,3,5,4,3,4,4);
@Course_Yardage =
(536,415,184,370,313,366,504,186,356,375,544,391,158,524,310,176,405,381);
@Course_Handicap = (10,2,8,6,18,4,12,14,16,13,7,3,17,9,15,11,1,5);
$prevname[0] = "";
$rounds = 0;
my $fline0;
my $i;
Open_Files ();
$i = 0;
$n = 0;
$lowsum = 0;
$highsum = 0;
ReadNextRec: while ( <IFD> )
{
Load_Stat_Rec ();
Process_Rec ();
}
Finish_Up ();
sub Compare_Player ()
{
printf ("\nIn Compare_Player ():\n");
printf (" Curr Name is %22s\n", @name[$i]);
printf (" Prev Name is %22s\n", @prevname[0]);
if (@name[$i] ne @prevname[0])
{
$z = 0;
if (@prevname[0] ne "")
{
Prnt_Player_Stats ();
}
Prnt_Header_info ();
@prevname[0] = @name[$i];
$n++;
}
} #end sub Compare_Player ()
sub Finish_Up ()
{
Prnt_Player_Stats ();
printf ("Number of records in %4u\n", $i);
printf ("Number of players in %4u\n", $n);
close IFD;
close OF;
close OF2;
} #end sub Finish_Up ()
sub Load_Stat_Rec ()
{
$fline0 = $_;
@name[$i] = substr $fline0,0,22;
@course[$i] = substr $fline0,22,2;
@tee[$i] = substr $fline0,25,2;
@team[$i] = substr $fline0,27,3;
@date[$i] = substr $fline0,31,10;
@nine[$i] = substr $fline0,42,1;
@score[$i] = substr $fline0,45,18; #046 - 063
@total[$i] = substr $fline0,64,2;
@handicap[$i] = substr $fline0,67,2;
@opponent[$i] = substr $fline0,70,2;
@week[$i] = substr $fline0,73,2;
@substitute[$i] = substr $fline0,75,22;
@notes[$i] = substr $fline0,98,25;
$q = 0;
$r = 0;
while ($q < 9)
{
@hole[$q] = substr @score[$i],$r,2;
if ((@hole[$q] eq 'X') or (@hole[$q] eq '0X'))
{
@hole[$q] = 10;
}
$r = $r + 2;
$q++;
}
if (@hole[$0] == 0)
{
last ReadNextRec;
}
} #end sub Load_Stat_Rec ()
sub Open_Files ()
{
open (IFD,"<C:/PERL/PGMS/stats2001.txt")
|| die "Can't open input file C:/PERL/PGMS/Stat2001.txt\n";
open (OF,">C:/PERL/PGMS/Rept2001.txt")
|| die "can't open output file C:/PERL/PGMS/Rept2001.txt\n";
open (OF2,">C:/PERL/PGMS/Summary_Rept2001.txt")
|| die "can't open output file C:/PERL/PGMS/Summary_Rept2001.txt\n";
for ($y = 0; $y < 12; $y++ )
{
@totover[$y] = 0;
}
while ($p < 18)
{
@overunder[$p] = 0;
@highscore[$p] = 0;
@lowscore[$p] = 10;
$p++;
}
} #end sub Open_Files ()
sub Process_Rec ()
{
printf (" prev Name is %22s\n", @prevname[0]);
Compare_Player ();
printf OF (" Date: %10s Week: %2s Handicap: %2s\n",
@date[$i],
@week[$i], @handicap[$i]);
printf OF ("
-----------------------------------------------------------\n");
printf OF (" Hole ");
$a = 1;
printf OF2 (" %10s", @date[$i]);
while ($a <= 9)
{
printf OF (" %3u", $a);
$a++;
}
printf OF ("\n Par ");
$a = 0;
while ($a < 9)
{
printf OF (" %3u", @Course_Par[$a]);
$a++;
}
printf OF ("\n
-----------------------------------------------------------\n");
$rndtot = 0;
$rounds++;
$q = 0;
printf OF (" Score ");
while ($q < 9)
{
printf OF (" %3u", @hole[$q]);
printf OF2 (" %3u", @hole[$q]);
$rndtot = $rndtot + @hole[$q];
$q++;
}
printf OF (" %3u %3u", @total[$i], $rndtot);
printf OF2 (" %3u %4u", $rndtot, @handicap[$i]);
printf OF ("\n");
printf OF2 ("\n");
printf OF ("
-----------------------------------------------------------\n");
Round_Stats ();
$i++;
} #end sub Process_Rec ()
sub Round_Stats ()
{
## calculate summary
for ($b = 0; $b < 12; $b++ )
{
@over[$b] = 0;
}
$s = 0;
do
{
$af = @hole[$s] - @Course_Par[$s];
if (@hole[$s] == 1)
{
@over[0]++;
@totover[0]++;
}
for ($xx=-2,$yy=1; $xx<=11; $xx++, $yy++)
{
if ($af == $xx)
{
@over[$yy]++;
@totover[$yy]++;
}
}
$s++;
$af = 0;
} until $s > 8;
## calculate averages
$p= 0;
while ($p < 9)
{
if (@hole[$p] > @highscore[$p])
{
@highscore[$p] = @hole[$p];
}
if (@hole[$p] < @lowscore[$p])
{
@lowscore[$p] = @hole[$p];
}
@sumhole[$p] = @sumhole[$p] + @hole[$p];
$p++;
}
Prnt_Round_Stats ();
} #end sub Round_Stats ()
sub Prnt_Header_info ()
{
printf ("\n curr Name is %22s Team : %3s\n", @name[$i], @team[$i]);
printf OF ("Golfer: %22s Team: %3s\n", @name[$i], @team[$i]);
printf OF2 ("Golfer: %22s Team: %3s\n", @name[$i], @team[$i]);
printf OF ("Course: %25s Tee: %7s Rating/Slope: %3u/%3u\n\n",
$Course_Name, $Course_Tee, $Course_Rate, $Course_Slope);
printf OF2 ("Course: %25s Tee: %7s Rating/Slope: %3u/%3u\n\n",
$Course_Name, $Course_Tee, $Course_Rate, $Course_Slope);
printf OF ("
=========================================================================\n");
printf OF2 ("
=========================================================================\n");
printf OF (" Hole ");
printf OF2 (" Hole ");
$a = 1;
while ($a <= 18)
{
printf OF (" %3u", $a);
printf OF2 (" %3u", $a);
$a++;
}
printf OF ("\n Yardage ");
printf OF2 ("\n Yardage ");
$a = 0;
while ($a < 18)
{
printf OF (" %3u", @Course_Yardage[$a]);
printf OF2 (" %3u", @Course_Yardage[$a]);
$a++;
}
printf OF ("\n Par ");
printf OF2 ("\n Par ");
$a = 0;
while ($a < 18)
{
printf OF (" %3u", @Course_Par[$a]);
printf OF2 (" %3u", @Course_Par[$a]);
$a++;
}
printf OF ("\n Handicap ");
printf OF2 ("\n Handicap ");
$a = 0;
while ($a < 18)
{
printf OF (" %3u", @Course_Handicap[$a]);
printf OF2 (" %3u", @Course_Handicap[$a]);
$a++;
}
printf OF ("\n
=========================================================================\n\n");
printf OF2 ("\n
=========================================================================\n\n");
} #end sub Prnt_Header_info ()
sub Prnt_Player_Stats ()
{
## print averages
printf OF2 ("
--------------------------------------------------\n");
printf OF2 (" Low : ");
$p= 0;
while ($p < 9)
{
printf OF2 (" %3u", @lowscore[$p]);
$lowsum = $lowsum + @lowscore[$p];
$p++;
}
$p= 0;
printf OF2 (" %3u\n High: ", $lowsum);
while ($p < 9)
{
printf OF2 (" %3u", @highscore[$p]);
$highsum = $highsum + @highscore[$p];
$p++;
}
printf OF2 (" %3u\n Avg : ", $highsum);
$p= 0;
$avgsum = 0;
while ($p < 9)
{
@avghole[$p] = @sumhole[$p]/$rounds;
printf OF2 (" %3.1f", @avghole[$p]);
$avgsum = $avgsum + @avghole[$p];
$p++;
}
printf OF2 (" %5.1f\n Par +/-: ", $avgsum);
$p= 0;
$sumoverunder = 0;
while ($p < 9)
{
@overunder[$p] = @avghole[$p] - @Course_Par[$p];
printf OF2 (" %3.1f", @overunder[$p]);
$sumoverunder = $sumoverunder + @overunder[$p];
$p++;
}
printf OF2 (" %5.1f\n", $sumoverunder);
printf OF2 ("
--------------------------------------------------\n\n");
$no_of_holes = 0;
for ($m = 0; $m < 18; $m++)
{
@percent[$m] = 0;
}
for ($f = 0; $f < 9; $f++)
{
$no_of_holes = $no_of_holes + @totover[$f];
}
printf (" # holes: %5u\n", $no_of_holes);
for ($e=0;$e<12;$e++)
{
if (@totover[$e] == 0)
{
@percent[$e] = 0;
}
else
{
@percent[$e] = (@totover[$e] * 100) / $no_of_holes;
}
printf (" %6.2f", @percent[$e]);
}
printf ("\n");
printf OF (" Player Summary:\n");
printf OF2 (" Player Summary: # of Rounds = %3u # of Holes = %5u\n",
$no_of_holes/9, $no_of_holes);
printf OF ("
-----------------------------------------------------------------\n");
printf OF2 ("
-----------------------------------------------------------------\n");
printf OF (" ACE : %2u %6.2f BOGEY : %2u %6.2f PLUS 5: %2u
%6.2f\n", @totover[0], @percent[0],
@totover[4], @percent[4], @totover[8]), @percent[8];
printf OF2 (" ACE : %2u %6.2f BOGEY : %2u %6.2f PLUS 5: %2u
%6.2f\n", @totover[0], @percent[0],
@totover[4], @percent[4], @totover[8]), @percent[8];
printf OF (" EAGLE : %2u %6.2f DOUBLE : %2u %6.2f PLUS 6: %2u
%6.2f\n", @totover[1], @percent[1],
@totover[5], @percent[5], @totover[9]), @percent[9];
printf OF2 (" EAGLE : %2u %6.2f DOUBLE : %2u %6.2f PLUS 6: %2u
%6.2f\n", @totover[1], @percent[1],
@totover[5], @percent[5], @totover[9]), @percent[9];
printf OF (" BIRDIE: %2u %6.2f TRIPLE : %2u %6.2f PLUS 7: %2u
%6.2f\n", @totover[2], @percent[2],
@totover[6], @percent[6], @totover[10], @percent[10]);
printf OF2 (" BIRDIE: %2u %6.2f TRIPLE : %2u %6.2f PLUS 7: %2u
%6.2f\n", @totover[2], @percent[2],
@totover[6], @percent[6], @totover[10], @percent[10]);
printf OF (" PAR : %2u %6.2f QUADRUPLE: %2u %6.2f PLUS 8: %2u
%6.2f\n", @totover[3], @percent[3],
@totover[7], @percent[7], @totover[11], @percent[11]);
printf OF2 (" PAR : %2u %6.2f QUADRUPLE: %2u %6.2f PLUS 8: %2u
%6.2f\n", @totover[3], @percent[3],
@totover[7], @percent[7], @totover[11], @percent[11]);
printf OF ("
-----------------------------------------------------------------\n\n\n");
printf OF2 ("
-----------------------------------------------------------------\n\n\n");
for ($c = 0; $c < 18; $c++ )
{
@totover[$c] = 0;
@avghole[$c] = 0;
@percent[$c] = 0;
@sumhole[$c] = 0;
@overunder[$c] =0;
@highscore[$c] = 0;
@lowscore[$c] = 10;
}
$lowsum = 0;
$highsum = 0;
$no_of_holes = 0;
$avgsum = 0;
$rounds = 0;
} #end sub Prnt_Player_Stats ()
sub Prnt_Round_Stats ()
{
for ($e=0;$e<12;$e++)
{
if (@over[$e] == 0)
{
@percent[$e] = 0;
}
else
{
@percent[$e] = (@over[$e] * 100) / 9;
}
}
printf OF (" Round Summary:\n");
printf OF ("
-----------------------------------------------------------------\n");
printf OF (" ACE : %2u %6.2f BOGEY : %2u %6.2f PLUS 5: %2u
%6.2f\n", @over[0], @percent[0],
@over[4], @percent[4], @over[8], @percent[8]);
printf OF (" EAGLE : %2u %6.2f DOUBLE : %2u %6.2f PLUS 6: %2u
%6.2f\n", @over[1], @percent[1],
@over[5], @percent[5], @over[9], @percent[9]);
printf OF (" BIRDIE: %2u %6.2f TRIPLE : %2u %6.2f PLUS 7: %2u
%6.2f\n", @over[2], @percent[2],
@over[6], @percent[6], @over[10], @percent[10]);
printf OF (" PAR : %2u %6.2f QUADRUPLE: %2u %6.2f PLUS 8: %2u
%6.2f\n", @over[3], @percent[3],
@over[7], @percent[7], @over[11], @percent[11]);
printf OF ("
-----------------------------------------------------------------\n\n");
for ($c = 0; $c < 18; $c++ )
{
@over[$c] = 0;
@percent[$c] = 0;
}
} #end sub Prnt_Round_Stats ()
=========================================================================
----Original Message Follows----
From: Mark Bergeron <[EMAIL PROTECTED]>
To: Al Hospers <[EMAIL PROTECTED]>, [EMAIL PROTECTED]
CC: [EMAIL PROTECTED]
Subject: Re: Re: Code Review
Date: Fri, 22 Jun 2001 11:52:57 -0700 (PDT)
Just insert your code insode the email itself so we can have a look that
way.
Mark Bergeron
-----Original Message-----
From: "Al Hospers"<[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Date: Fri Jun 22 11:08:23 PDT 2001
Subject: Re: Code Review
>PLEASE do NOT send attachments to the list.
>
>Al Hospers
>CamberSoft, Inc.
>al<at>cambersoft<dot>com
>http://www.cambersoft.com
>
>A famous linguist once said:
>"There is no language wherein a double
>positive can form a negative."
>
>YEAH, RIGHT
>
>
/~_. _ | _ _ _ _
\_/|(_||| | |(_)| |
_|
___________________________________________________
GO.com Mail
Get Your Free, Private E-mail at http://mail.go.com
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com