# Copyright 2001-2003 by Jay F. Davis, webtoad@earthlink.net # For free use under terms of the Perl Artistic License which can be found at www.perl.com. # Please make a reasonable effort to send changes and improvements to the author. use strict; use English; my $line; my $pitcher; my $cnt; my $catcher; my $infielder; my $outfielder; my $folder = "./rosters"; my @files; my $team; my $output; open OUT, ">./roster.txt" or die "Couldn't open roster.txt for writing.";; opendir DIR, $folder or die "Can't open folder $folder.\n"; chdir $folder or die "Couldn't change directory to $folder.\n"; @files = readdir DIR; foreach (@files) { $team = $ARG; print $team . "\n"; open IN, $team; if ($team eq "angels.html") { $team = "ANA"; } elsif ($team eq "astros.html") { $team = "HOU"; } elsif ($team eq "athletics.html") { $team = "OAK"; } elsif ($team eq "bluejays.html") { $team = "TOR"; } elsif ($team eq "braves.html") { $team = "ATL"; } elsif ($team eq "brewers.html") { $team = "MIL"; } elsif ($team eq "cardinals.html") { $team = "STL"; } elsif ($team eq "cubs.html") { $team = "CHN"; } elsif ($team eq "dbacks.html") { $team = "ARI"; } elsif ($team eq "devilrays.html") { $team = "TAM"; } elsif ($team eq "dodgers.html") { $team = "LOS"; } elsif ($team eq "expos.html") { $team = "MON"; } elsif ($team eq "giants.html") { $team = "SFO"; } elsif ($team eq "indians.html") { $team = "CLE"; } elsif ($team eq "mariners.html") { $team = "SEA"; } elsif ($team eq "marlins.html") { $team = "FLA"; } elsif ($team eq "mets.html") { $team = "NYM"; } elsif ($team eq "orioles.html") { $team = "BAL"; } elsif ($team eq "padres.html") { $team = "SDG"; } elsif ($team eq "phillies.html") { $team = "PHI"; } elsif ($team eq "pirates.html") { $team = "PIT"; } elsif ($team eq "rangers.html") { $team = "TEX"; } elsif ($team eq "reds.html") { $team = "CIN"; } elsif ($team eq "redsox.html") { $team = "BOS"; } elsif ($team eq "rockies.html") { $team = "COL"; } elsif ($team eq "royals.html") { $team = "KAN"; } elsif ($team eq "tigers.html") { $team = "DET"; } elsif ($team eq "twins.html") { $team = "MIN"; } elsif ($team eq "whitesox.html") { $team = "CHA"; } elsif ($team eq "yankees.html") { $team = "NYY"; } $pitcher = "n"; $catcher = "z"; $infielder = "z"; $cnt = 0; # assume DOS file format $INPUT_RECORD_SEPARATOR = "\r\n"; while () { $line = $ARG; #print $line . "\n"; chomp $line; # pitchers if (substr($line, 10, 9) eq "\tPITCHERS") { $pitcher = "y"; $cnt = 1; } if ($pitcher eq "y" && $cnt > 0) { if ($cnt > 1 && $line ne "") { $output = $team . "\t" . $line . " [P]\n"; print $output; syswrite OUT, $output, length($output); } if ($line eq "") { $catcher = "n"; $pitcher = "n"; } $cnt++; } # catchers if ($catcher eq "n" && substr($line, 10, 9) eq "\tCATCHERS") { $catcher = "y"; $cnt = 1; } if ($catcher eq "y" && $cnt > 0) { if ($cnt > 1 && $line ne "") { $output = $team . "\t" . $line . " [C]\n"; print $output; syswrite OUT, $output, length($output); } if ($line eq "") { $infielder = "n"; $catcher = "n"; } $cnt++; } # infielders/outfielders/others if ($infielder eq "n" && substr($line, 10, 11) eq "\tINFIELDERS") { $infielder = "y"; $cnt = 1; } if ($infielder eq "y" && $cnt > 0) { if ($cnt > 1 && $line ne "" && substr($line, 0, 2) ne "NO" && substr($line, 0, 4) ne "
") { $output = $team . "\t" . $line; # trim off junk after [POS] $output =~ s/(\].*)/\]/; $output .= "\n"; print $output; syswrite OUT, $output, length($output); } if ($line eq "
") { last; } $cnt++; } } close IN; } close OUT;