open(INPUT,"c:/MLB_boxscore.TXT") or die "Can't open file"; print "My page"; print ""; my $insection = ""; while () { if (/^SAC\s+BUNTS/) { $insection="sac bunts" } if (/^SAC\s+FLIES/) { $insection="sac flies" } if (/^STOLEN\s+BASES/) { $insection="stolen bases" } if (/^CAUGHT\s+STEALING) { $insection="caught stealing" } if (/^PITCHING/) { $insection="pitching" } if(defined($oldsection) && $insection ne $oldsection) { undef $oldsection; } elsif (defined($oldsection) && $insection eq $oldsection) { if ($insection == "scoring position"){ last if /^([A-Z][A-Z\s]*)/; chomp; @LS = (); push @LS, split('\|',$_); print ""; print "" for (1..$#LS); print ""; } } elsif ($insection && !defined($oldsection)) { $oldsection = $insection; next; } } print "
" . $LS[$_] . "
"; close INPUT;