Perl for Football Tipping

Jim O'Halloran • March 28, 2003

perl

The AFL footy season is upon us again, which in most offices means football tips... I don't follow the footy, but I do go in the tipping comps for a bit of fun. The AFL web site has an "Expert Tips" page, so this year I decided to do something a bit different and write a perl script to do most of my footy tips for me :) Perl script is below...

#!/usr/bin/perl -w
#
#AFL Footie Tipping
#
#Author: jim@jimohalloran.com
#

#Configurable Items
$TIP_URL = "http://afl.com.au/default.asp?pg=tipsters&spg=default";
$TIP_PREFIX = "class\=p3\>";

#Download Page
$TipPage =`wget "$TIP_URL" -q -O -`;

@HTMLLines = split(/\n/, $TipPage);
foreach $ThisOne (@HTMLLines) {
  if ( ($Team) = ($ThisOne =~ /$TIP_PREFIX([A-Za-z ]+)/) ) {
    $Tipped{$Team}++;
  };
};

foreach $ThisOne (sort {$Tipped{$b}$Tipped{$a} } keys %Tipped) {
  print "$ThisOne  was picked " . $Tipped{$ThisOne} . " time(s)\n";
};

... run the script once each week, and it'll show you who the experts tipped. Then go through the fixture for the current week and pick whichever team the experts tipped most.

One day I might automate the last part and submit my tips using a cron job, but it does the job for now :)

UPDATE: I've updated the script with a few enhanced features, and posted it here