in reply to Parsing a Text File 2
there's probably a better way to do it - but this works. NOTE: You must add if statements for all headings you wish to stop at (following my example of the DOUBLE PLAYS match). HTH!my $insection = ""; while (<INPUT>) { if (/^PITCHING/) { $insection="pitching" } if (/^DOUBLE\s+PLAYS/) { $insection="double plays" } if(defined($oldsection) && $insection ne $oldsection) { undef $oldsection; } elsif (defined($oldsection) && $insection eq $oldsection) { #print the HTML forms here } elsif ($insection && !defined($oldsection)) { $oldsection = $insection; next; } }
|
|---|