open(INPUT,"c:/MLB_boxscore.TXT") or die "Can't open file";
print "
Box Score";
print "";
my $insection = "";
my $hr, $db, $hrd, $y, $l, $linescore;
$hr = 0;
$db = 0;
$hrd = 0;
$y = 0;
$l = 0;
$v = 0;
$h = 0;
$linescore = 0;
while () {
if ($y eq 4){$linescore = -1}
else {$linescore = 0}
if ($linescore eq 0){
linescore($y, $l);
$y = $x;
}
if ($linescore ne 0){
sub linescore {
if (/^\s*$/) {
$l = 0;
$y += 1;
$b = 0;
}
else {
if ($y eq 0){
players($y, $l);
$v_team = $team;
$b = $b;
$l = $l;
$v_line[$b] = $line;
return $v_line[$b], $l;
}
if ($y eq 1){
totals($y);
$b = $b;
$v_total[$b] = $total;
return $v_total[$b];
}
if ($y eq 2){
players($y);
return $h_team = $team;
$b = $b;
return $h_line[$b] = $line;
}
if ($y eq 3){
totals($y);
$b = $b;
return $h_total[$b] = $total;
}
}
$x = $y;
return $x, $l;
}
sub players{
if ($l eq 0){
chomp;
@LS = ();
push @LS, split('\|',$_);
$team = $LS[0];
$l = 1;
return $team, $l;
}
if ($l ne 0){
print "mike";
my @linescores = (0,2,3,4,5,6,7,8,9,10,11,12,13);
chomp;
@LS = ();
push @LS, split('\|',$_);
my $line = "";
for ($i=0;$i<$#LS;$i++){
$a = $linescores[$i];
$linescore[$i] = $LS[$a];
print $linescore[$i];
}
my $line = $line . "";
for ($x=1;$x<=$#linescore;$x++){
$line = $line . "| " . $linescore[$x] . " | ";
$linescore[$x] = undef;
}
$line = $line . "
";
$b += 1;
return $line, $b;
}
}
sub totals{
my @totals = (0,4,5,6,7,8,9,10);
chomp;
@LS = ();
push @LS, split('\|',$_);
my $total = "";
for ($i=0;$i<$#LS;$i++){
$a = $totals[$i];
$tot[$i] = $LS[$a];
}
my $total = $total . "";
for ($x=1;$x<=$#tot;$x++){
$total = $total . "| " . $tot[$x] . " | ";
$tot[$x] = undef;
}
$total = $total . "
";
$b += 1;
return $total, $b;
}
print "
";
print "";
close INPUT;