#!/usr/bin/perl use strict; use warnings; my $DATFILE = "c:/store.txt"; my @teams = qw( Arsenal Bolton Villa Chelsea Middlesbrough ` Newcastle Birmingham Blackburn Palace Fulham Liverpool ManchesterCity Norwich Portsmouth Spurs WBA ManchesterUnited Southampton Charlton Everton ); clearscreen(); # if we don't have a datfile we HAVE to INIT it!!! init_file(\@teams) unless -e $DATFILE; # now we can read the datfile becuase it exists, 100% guaranteed open F, $DATFILE or die "Can't read $DATFILE, Perl says $!\n"; chomp ( my @values = ); close F; print " --------------------------- 1. Update Teams 2. Check previous Results 3. Backup Storage File 4. Quit --------------------------- Option: "; chomp( my $reply = ); clearscreen(); if ($reply == "0") { init_file(\@teams); } elsif ($reply == "1") { team_update(\@values, \@teams); } elsif ($reply == "2") { team_find(\@values); } elsif ($reply == "3") { storage_backup(); } else { print "Exiting\n"; } exit 0; #----------------------------------------------------------------- # subs #----------------------------------------------------------------- sub clearscreen { $^O =~ m/Win32/ ? system('cls') : system('clear') } sub init_file { my ($teams) = @_; open F, ">$DATFILE" or die "Can't write $DATFILE, Perl say $!\n"; print F "$_\n" for @$teams; close F; } # yada