in reply to Parsing a Text File

The reason is because when this line:
last if /^\s*$/;
parses the blank line after the Cardinals, it stops. So change that line to:
last if /^END PITCHING/;
and add 'END PITCHING' on a line by itself after the last line for the Reds.

Also, you can get rid of all 16 TD prints with this one line:

print "<td>$_</td>" foreach @LS;
UPDATE: Oops, you don't want to print the first element, so use this:
print "<td>" . $LS[$_] . "</td>" for (1..$#LS);
and good advice suaveant!

Jeff

R-R-R--R-R-R--R-R-R--R-R-R--R-R-R--
L-L--L-L--L-L--L-L--L-L--L-L--L-L--

Replies are listed 'Best First'.
Re: (jeffa) Re: Parsing a Text File
by suaveant (Parson) on Apr 11, 2001 at 23:19 UTC
    Another way without changing the text might be
    last if /^[A-Z]+$/;
    which will make it stop as soon as it hits a line that only has capitol letters in it.
                    - Ant
      Thanks for the help. I changed my code up and it is doing what I had intended, however, it is picking up the first line of DOUBLE PLAYS. Any suggestions would be appreaciated.
      open(INPUT,"c:/MLB_boxscore.TXT") or die "Can't open file"; print "<html><head><title>My page</title></head><body>"; print "<table>"; $pitching = 0; while(<INPUT>) { if($pitching) { last if /^[A-Z]+$/; chomp; @LS = (); push @LS, split('\|',$_); print "<tr>"; print "<td>" . $LS[$_] . "</td>" for (1..$#LS); print "</tr>"; } elsif(/^PITCHING/) { $pitching = 1} } print "</table></body></html>"; close INPUT;
        ooops, sorry!
        last if /^[A-Z\s]+$/;
        that will allow all caps and whitespace only
                        - Ant