my @superbowls = ( i, ii, iii, iv, v, vi, vii, viii, ix, x, xi, xii, xiii, xiv, xv, xvi, xvii, xviii, xix, xx, xxi, xxii, xxiii, xxiv, xxv, xxvi, xxvii, xxviii, xxix, xxx, xxxi, xxxii, xxxiii, xxxiv, xxxv, xxxvi, xxxvii, xxxviii, xxxix, xl); # Keep running total of scores my @scores = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0); $urlBase = "http://superbowl.com/history/boxscores/game/sb"; # create 'data' dir if (!(-d "data")) { system ("mkdir data") and die $!; } for $num (@superbowls){ # next unless $num eq "i"; print "Processing: $urlBase$num\n"; if (!(-e "data/$num.txt")) { system("wget $urlBase$num -O data/$num.txt"); } open(FILE, "data/$num.txt") or die $!; while ($l = ) { if ($l =~ /SCORING/) { $l = ; parseLine($l); $l = ; parseLine($l); } } close(FILE); } sub parseLine { my $line = shift; if ($line =~ /^(.+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+\-\-\s+(\d+)/) { $team1 = $1; $q1 = $2; $q2 = $q1 + $3; $q3 = $q2 + $4; $q4 = $q3 + $5; print "$team1: $q1, $q2, $q3, $q4 -> $6\n"; # Add to array addScore($q1); addScore($q2); addScore($q3); addScore($q4); } else { die "Did not find team scores in line: $line"; } } sub addScore { my $score = shift; my $ones = $score % 10; #print "ones of $score is $ones\n"; $scores[$ones]++; } # Print scores: print "\n** RESULTS **\n"; $i = 0; while ($i <= 9) { print "Digit $i: $scores[$i]\n"; $i++; }