use strict; use warnings; use Data::Dumper; use HTML::FormatText::WithLinks::AndTables; use IO::File; use LWP::Simple; my %teamCodes; $teamCodes{"ATL"} = "atl"; ## Atlanta Falcons $teamCodes{"CHI"} = "chi"; ## Chicago Bears $teamCodes{"CIN"} = "cin"; ## Cincinnati Bengals $teamCodes{"CLE"} = "cle"; ## Cleveland Browns $teamCodes{"BUF"} = "buf"; ## Buffalo Bills $teamCodes{"DAL"} = "dal"; ## Dallas Cowboys $teamCodes{"DEN"} = "den"; ## Denver Broncos $teamCodes{"DET"} = "det"; ## Detroit Lions $teamCodes{"GNB"} = "gnb"; ## Green Bay Packers $teamCodes{"HOO"} = "hoo|oti"; ## Houston Oilers $teamCodes{"IND"} = "ind|clt"; ## Indianapolis Colts $teamCodes{"NYJ"} = "nyj"; ## New York Jets $teamCodes{"KAN"} = "kan"; ## Kansas City Chiefs $teamCodes{"LAM"} = "lam|ram"; ## Los Angeles Rams $teamCodes{"LAD"} = "lad|rai"; ## Los Angeles Raiders $teamCodes{"MIA"} = "mia"; ## Miami Dolphins $teamCodes{"MIN"} = "min" ; ## Minnesota Vikings $teamCodes{"NYG"} = "nyg" ; ## New York Giants $teamCodes{"NWE"} = "nwe" ; ## New England Patriots $teamCodes{"NOR"} = "nor"; ## New Orleans Saints $teamCodes{"PHI"} = "phi"; ## Philadelphia Eagles $teamCodes{"PIT"} = "pit"; ## Pittsburgh Steelers $teamCodes{"SEA"} = "sea"; ## Seattle Seahawks $teamCodes{"SDG"} = "sdg"; ## San Diego Chargers $teamCodes{"SFO"} = "sfo"; ## San Francisco 49ers $teamCodes{"SLC"} = "slc|crd"; ## St. Louis Cardinals $teamCodes{"TAM"} = "tam"; ## Tampa Bay Buccaneers $teamCodes{"WAS"} = "was"; ## Washington Redskins my $date1 = "198509080"; my $date2 = "198509090"; my $tKey; my $link ; my $abbriv; my $urlBase = "http://www.pro-football-reference.com/boxscores/"; my $webPageText ; my @teamCode ; my $delimiter = quotemeta("|" ); my $startGameInfo ; my $startGameInfoTbl; my $endGameInfoTbl; my $gameInfoTbl ; while ( ($tKey, $abbriv) = each %teamCodes) { @teamCode = split( /$delimiter/, $abbriv ) ; print "$teamCode[0] \n"; } while ( ($tKey, $abbriv) = each %teamCodes) { @teamCode = split( /$delimiter/, $abbriv ) ; $link = $urlBase . $date1. $teamCode[0] . ".htm" ; print $link; $webPageText = get( $link ) or print "failed on retrieve of web page\n"; if (index( $webPageText, "File Not Found") > 0 ) { print " failed on retrieve of web page\n"; } else { print "\n$webPageText\n\n"; if ( $startGameInfo = index( $webPageText, "Game Info") ) { $startGameInfoTbl = rindex($webPageText, "", $startGameInfo ); $gameInfoTbl = substr($webPageText, $startGameInfoTbl, $endGameInfoTbl - $startGameInfoTbl +9); print $gameInfoTbl; my $converted = HTML::FormatText::WithLinks::AndTables->convert( $gameInfoTbl ); my @lines = split /\n+/, $converted; my $arraySize = @lines; print "\narray size = $arraySize\n"; } } }