There are more fields in the text file. The above is just two of the fields. I need the sub to be able to go through each line until it reaches a blank space. The sub would only do Doubles or Home Runs. So, if I were trying to pull out Doubles, after the sub was run, it would stop at the whitespace after Doubles. At that point the sub should end. As is, the sub will only go through one line of data before ending. Any suggestions?DOUBLES 5046|Craig Paquette|24|St. Louis Cardinals|1|5 5508|Juan Castro|17|Cincinnati Reds|1|1 HOME RUNS 5151|Jim Edmonds|24|St. Louis Cardinals|1|11 3866|Mark McGwire|24|St. Louis Cardinals|1|11 4305|Ken Griffey Jr.|17|Cincinnati Reds|1|8
#Our Sub sub score { if(defined($oldsection) && $insection ne $oldsection) { undef $oldsection; } elsif (defined($oldsection) && $insection eq $oldsection) { if ($insection ne "pitching") { last if /^([A-Z][A-Z\s]*)/; chomp; @LS = (); push @LS, split('\|',$_); print "<tr>"; print "<td>" . $LS[$_] . "</td>" for (1..$#LS); print "</tr>"; } } elsif ($insection && !defined($oldsection)) { $oldsection = $insection; next; } $insection = ""; }
In reply to Looping Through a Sub by Perl Newby
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |