split function question

2001-06-28 Thread Brian Bukeavich

I need a little help with the split function. I'm trying to split a line 
based on comma delimeters(,), but when I use the syntax below I don't get 
the results I expect.  What am I doing wrong?  Is there a an special escape 
sequence for a comma?

my @asLine = split (/,/, $_);


Thanks
_
Get your FREE download of MSN Explorer at http://explorer.msn.com




Re: Re: Code Review

2001-06-22 Thread Brian Bukeavich

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);