#!/usr/bin/perl -w use strict; use DBI; #my fledgling attempt at a Fantasy AFL comp #this file reads the downloaded weekly scores and inserts them #into a datbase #open the source file for weekly statistics my $weekly_file = shift || 'weekly'; # you can specify a team file on the command # line or take the default #set variables for the database my $dsn="dbi:mysql:database=fflnew"; my $user="root"; my $pass=""; my $dbh = DBI->connect($dsn, $user, $pass) || die "Could not connect: $DBI::errstr\n"; open WEEKLY, "< $weekly_file" or die "Cannot open $weekly_file for reading:$!"; while () { my ($round,$playername,$kick,$handpass,$possess,$mark,$hitout,$tackle,$freefor,$freeagainst,$goal,$behind) = ("","","","","","","","","","","",""); ($round,$playername,$kick,$handpass,$possess,$mark,$hitout,$tackle,$freefor,$freeagainst,$goal,$behind)= split( /,/ ); my $sth = $dbh->prepare("INSERT into ffl_weekly (score_ID,round,playername,kick,handpass,posession,mark,hitout,tackle,freefor,freeagainst,goal,behind,total) values (NULL,?,?,?,?,?,?,?,?,?,?,?,?,NULL)"); $sth->execute($round,$playername,$kick,$handpass,$possess,$mark,$hitout,$tackle,$freefor,$freeagainst,$goal,$behind); #close and commit changes } close WEEKLY|| die "Cannot close $weekly_file, $!"; $dbh->disconnect();