#!/usr/bin/perl -w

use strict;

my $new_score = 12763;
my $list = "highs.log";
my @highs;

## add new_score to list, then resort and pull off the lowest score

# get current high scores
open(LIST, "$list");
while ( <LIST> ) {
	@highs = <LIST>
}
close LIST;

# add new score to list
push @highs, $new_score;

# sort list
my @sorted = sort{$b <=> $a} @highs;

# drop lowest score
pop (@highs);

## clear current highs.log
open(TMP, "+>$list");
close TMP;

## write new high score list
open(NEW, "+>>$list");
my $i = 0;
while (defined $sorted[$i]) { $i++; }
foreach my $loop (0..$i) {
	if ($loop == 0) { print NEW "$sorted[$loop]\n"; }
	else { print NEW "$sorted[$loop]"; }
}

